This exercise will help you become more familiar with the Scanner class as well as working with a two class app.
This console based app will ask the user to enter a GymMembers details. These details will then be printed back to the console.
During this challenge, you may need to view this weeks and last weeks lecture notes to remind you how to write classes. The SpotConsoleV1.0 (particularly for validation) and the ShopV1.0 solution will also be useful here.
In IntelliJ, create a new Java Project called GymApp1.0.
Within this project, create two new Classes; GymMember and Driver.
In the GymMember class, create five private instance fields:
The default values for these fields are as follows:
The validation for these fields is as follows:
Write a constructor for this class that takes the five instance fields as parameters and updates the object state using these parameters.
Write a getter for each instance field.
Write a setter for each instance field.
Write a toString method that builds and returns a String comprising a user friendly representation of the object state.
In the Driver class, create two private instance fields:
Write a method called addGymMember()) that asks the user to input the gym member details (name, height, weight, membership number and if they are a current member). Use this data to create a new GymMember object.
Write a method called printGymMember() that prints all the gymMember details to the console.
Hint: use the toString() method from the GymMember class.
Write a main method that calls the Driver() constructor.
Write a Driver() constructor that calls both the addGymMember()) and printGymMember() methods.
Run the app; does all work as expected? Are you asked to enter the gym members details? Are all details you entered printed back to the console?