Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create java classes: Notice that this is a class hierarchy so some classes will

ID: 669758 • Letter: C

Question

Create java classes: Notice that this is a class hierarchy so some classes will build on (extend) other classes. Each class is listed along with its class data members (variables). All variables should be declared private. Do not change the names of the variables and make sure set and get methods are named following Java naming conventions. If you are unfamiliar with Java method naming conventions, you can use the built in code generator in Netbeans to generate the correct names for the setters and getters. In addition to the class variables listed below, you will supply the following methods for each class.

1) set/get methods for all variables. The set method will take one argument which will be the value to set the variable to. The get method will return the value of the variable. You can auto-generate these methods using the built in code generator in Netbeans.

2) toString This method will return a formatted string containing all of the values for the variables. You can auto-generate this method using the built in code generator in Netbeans.

Classes:

1) Person. var: name(string), address(string), socialsecuritynumber(string: format: 999999999), dateofbirth (string: format: mmddyyyy)

2) Student (extends Person). var: currentGPA(float), dateofgraduation(string), courses(array list.. this will contain a list of courses the student is enrolled in)

3) Faculty (extends Person) var: dateOfHire(String:(format: mmddyyyy)), salary (double), courses(ArrayList)(This will contain a list of courses the faculty teaches)

4) Classroom. var: roomNumber(string), roomType(String)

5)Course. var: room(string), coursename(string), courseNumber(float)

Explanation / Answer

Person.java

public class Person {
   private String name;
   private String address;
   private String socialsecuritynumber;
   private String dateofbirth;

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public String getAddress() {
       return address;
   }

   public void setAddress(String address) {
       this.address = address;
   }

   public String getSocialsecuritynumber() {
       return socialsecuritynumber;
   }

   public void setSocialsecuritynumber(String socialsecuritynumber) {
       this.socialsecuritynumber = socialsecuritynumber;
   }

   public String getDateofbirth() {
       return dateofbirth;
   }

   public void setDateofbirth(String dateofbirth) {
       this.dateofbirth = dateofbirth;
   }
  
   public String toString(){
   String string = "Name: "+name+" Address: "+address+" Social Security Number: "+socialsecuritynumber+" Date of Birth: "+dateofbirth;
   return string;
   }

}

Student.java

import java.util.ArrayList;

public class Student extends Person {
   private float currentGPA;
   private String dateofgraduation;
   private ArrayList<Course> courses;

   public float getCurrentGPA() {
       return currentGPA;
   }

   public void setCurrentGPA(float currentGPA) {
       this.currentGPA = currentGPA;
   }

   public String getDateofgraduation() {
       return dateofgraduation;
   }

   public void setDateofgraduation(String dateofgraduation) {
       this.dateofgraduation = dateofgraduation;
   }

   public ArrayList<Course> getCourses() {
       return courses;
   }

   public void setCourses(ArrayList<Course> courses) {
       this.courses = courses;
   }

   public String toString() {
       String cours = " ";
       for (int i = 0; i < courses.size(); i++)
           cours = cours + courses.get(i).getCoursename() + " ";
       String string = "Current GPA: " + currentGPA + " Date of Graduation: "
               + dateofgraduation + " Courses: " + cours;
       return string;
   }

}

Faculty.java

import java.util.ArrayList;

public class Faculty extends Person {
   private String dateOfHire;
   private double salary;
   private ArrayList<Course> courses;

   public String getDateOfHire() {
       return dateOfHire;
   }

   public void setDateOfHire(String dateOfHire) {
       this.dateOfHire = dateOfHire;
   }

   public double getSalary() {
       return salary;
   }

   public void setSalary(double salary) {
       this.salary = salary;
   }

   public ArrayList<Course> getCourses() {
       return courses;
   }

   public void setCourses(ArrayList<Course> courses) {
       this.courses = courses;
   }

   public String toString() {
       String cours = " ";
       for (int i = 0; i < courses.size(); i++)
           cours = cours + courses.get(i).getCoursename() + " ";
       String string = "Date of Hire: " + dateOfHire + " Salary: " + salary
               + " Courses: " + cours;
       return string;
   }

}

Classroom.java

public class Classroom {
   private String roomNumber;
   private String roomType;

   public String getRoomNumber() {
       return roomNumber;
   }

   public void setRoomNumber(String roomNumber) {
       this.roomNumber = roomNumber;
   }

   public String getRoomType() {
       return roomType;
   }

   public void setRoomType(String roomType) {
       this.roomType = roomType;
   }

   public String toString() {
       return "Room Number: " + roomNumber + " Room Type: " + roomType;
   }
}

Course.java

public class Course {
   private String room;
   private String coursename;
   private float courseNumber;

   public String getRoom() {
       return room;
   }

   public void setRoom(String room) {
       this.room = room;
   }

   public String getCoursename() {
       return coursename;
   }

   public void setCoursename(String coursename) {
       this.coursename = coursename;
   }

   public float getCourseNumber() {
       return courseNumber;
   }

   public void setCourseNumber(float courseNumber) {
       this.courseNumber = courseNumber;
   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote