Allan Didier

Student Account

Goals

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.

  1. Student Account Class
    1. 3 private Data Variables
      1. String Student’s Name
      2. String Student’s Address
      3. Int Student’s Graduation Year
    2. Methods
      1. Two Constructors methods
        1. One with no parameters and asks the user to enter the data.
        2. One which sets all three variables by passing the values in directly as parameters.
      2. Three Accessor methods (getters)
        1. One for each of the above data variables.
        2. Returns the appropriate value.
        3. Eclipse can generate these automatically.
      3. Seven Mutator methods (setters)
        1. You can have Eclipse automatically create the setters, but you will have to modify them.
        2. Two setName methods
          1. One passes in the new name as the parameter.
          2. One has no parameters and will ask the user to enter a new name.
          3. Both make the change in the user name.
          4. Both output that the name has been changed from the old to the new name.
        3. Two setAddress methods
          1. One passes in the new address as the parameter.
          2. One has no parameters and will ask the user to enter a new address.
          3. Both make the change to the address
          4. Both output that the address has been changed from the old to the new address.
        4. Three setGradYear methods
          1. One passes in the new int year as the parameter.
          2. One passes in a string as the parameter.
            1. Possible strings include (ignore case): Senior, Junior, Sophomore, Freshmen
            2. It will calculate the year based on the string. Seniors graduate in 2019, etc.
          3. One has no parameters and asks the user to input the information.
          4. All will set the new graduation year.
          5. All will output that the year has been changed from the old to the new.
        5. toString method
          1. Outputs all of the account information in a clean and readable format.
  2. Main Program:
    1. Create two different student objects
      1. One is initialized with one constructor,
      2. The other is instantiated using other constructor.
      3. Output their initial values.
    2. Modify the two students
      1. Modify the information of both students using the Setter methods.
      2. Run three on one students.
      3. Run the other four on the other student.
      4. Output their final values.

Resources

Edhesive Term 2

Lesson 2: Method overloading