Question: 3. Write a Java program the design the following calss: [4 marks] Build a class GymMember that has the following: a. Attributes: name (String), ID(int),
3. Write a Java program the design the following calss: [4 marks] Build a class GymMember that has the following: a. Attributes: name (String), ID(int), JoiningDate (Date class). Use this for date type: Date JoiningDate = new Date(int year, int month, int date) Refer to this site for details on how to use Date class in Java: https://www.geeksforgeeks.org/date-class-java-examples/ b. Build a constructor that accepts three parameter name, ID, and Joining date. Then initialize the objects' attributes. c. Build a default constructor with empty body and no parameters. d. In the main method, create two GymMember objects gl and g2 using value constructor with arguments (parameters); and print their ids. e. Also, in the main method, create a third GymMember object g3 using the default constructor. f. Call a method CheckJoiningDate() on this object g3. g. Print the result of CheckJoiningDate() method. h. In the GymMember class, build a method named CheckJoiningDate0 that has no parameters. The method checks the joining date of this object g3, and if the joining year 2019 or before; prints the following: "Congratulations, you've earned a free membership next month (
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
