Question: Create a class hierarchy representing Students in a university. You know that Students are a type of Person, but Students have more specific characteristics like
Create a class hierarchy representing Students in a university. You know that Students are a type of Person, but Students have more specific characteristics like having a grade point average (GPA), student identification number (ID) and a discipline of study, or major (Mathematics, Computer Science, Literature, Psychology, etc.). Create a subclass of Person called Student using the code for Person below and the specifications listed below:
Students have personal data that helps identify them to university administrators. Create variables for a Student ID number, a GPA, which gives the average grade points for the student, a major, degree that he or she is earning (Bachelor's, Masters, Ph.D), and his or her expected graduation year. Carefully consider whether these should be public or private data.
For methods you declare private, you may want to provide access methods for other classes to retrieve this data.
Create a detailed UML diagram listing all of the data and methods of each class (for both Person and Student).
Create a method that allows administrators to change a student's major
Create a method that calculates a student's GPA by taking in an array of his or her grades. Take the average of all of the student's grades using the following breakdown.
| Grade | Grade Point Equivalent |
| A | 4 |
| A- | 3.67 |
| B+ | 3.33 |
| B | 3 |
| B- | 2.67 |
| C+ | 2.33 |
| C | 2 |
| D | 1 |
| F | 0 |
Code for Person class:
import java.util.Date;
public class Person {
private String firstName;
private String middleName;
private String lastName;
private Date dateOfBirth;
public Person(String firstName, String middleName,
String lastName, Date dateOfBirth){
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
}
/**
* Returns a String of the firstName
* @return firstName
*/
public String getFirstName(){
return firstName;
}
/**
* Returns a string of the middleName
* @return middleName
*/
public String getMiddleName(){
return middleName;
}
/**
* Returns a String of the lastName
* @return lastName
*/
public String getLastName(){
return lastName;
}
/**
* Returns a concatenated string of the Person's name
* @return the Person's first, middle, and last name.
*/
public String getName(){
return firstName + " " + middleName + " " + lastName;
}
/**
* Returns the Person's date of birth as a date type
* @return a Date type of the Person's date of birth.
*/
public Date getDateOfBirth(){
return dateOfBirth;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
