Goals
This assignment is optional. It is designed for students who need extra practice or review with object oriented programming.
Students will demonstrate their understanding of object instantiation, class creation and the use of constructor, accessor, and mutator methods in Java by creating a student account program following the details below and the programming rubric.
Skills
- Method overloading
Program Details
Create a program that can create, access and modify a basic student accounts from a student account class.
- Student Account Class
- 3 private Data Variables
- String Student’s Name
- String Student’s Address
- Int Student’s Graduation Year
- Methods
- Two Constructors methods
- One with no parameters and asks the user to enter the data.
- One which sets all three variables by passing the values in directly as parameters.
- Three Accessor methods (getters)
- One for each of the above data variables.
- Returns the appropriate value.
- Eclipse can generate these automatically.
- Seven Mutator methods (setters)
- You can have Eclipse automatically create the setters, but you will have to modify them.
- Two setName methods
- One passes in the new name as the parameter.
- One has no parameters and will ask the user to enter a new name.
- Both make the change in the user name.
- Both output that the name has been changed from the old to the new name.
- Two setAddress methods
- One passes in the new address as the parameter.
- One has no parameters and will ask the user to enter a new address.
- Both make the change to the address
- Both output that the address has been changed from the old to the new address.
- Three setGradYear methods
- One passes in the new int year as the parameter.
- One passes in a string as the parameter.
- Possible strings include (ignore case): Senior, Junior, Sophomore, Freshmen
- It will calculate the year based on the string. Seniors graduate in 2021, etc.
- One has no parameters and asks the user to input the information.
- All will set the new graduation year.
- All will output that the year has been changed from the old to the new.
- toString method
- Outputs all of the account information in a clean and readable format.
- Two Constructors methods
- 3 private Data Variables
- Main Program:
- Create two different student objects
- One is initialized with one constructor,
- The other is instantiated using other constructor.
- Output their initial values.
- Modify the two students
- Modify the information of both students using the Setter methods.
- Run three on one students.
- Run the other four on the other student.
- Output their final values.
- Create two different student objects
Resources
Java Textbook
Chapter 7: Object Oriented Design