Question
Person.java A very simple class which models some of the functionality of a person. This class is complete and must not be modified. Student.java A
Person.java A very simple class which models some of the functionality of a person. This class is complete and must not be modified.
Student.java A very simple class which extends the Person class to also model some of the functionality of a student. This class is complete and must not be modified.
Principle.java A very simple class which extends the Person class to also model some of the functionality of a principle. The extra data member this time is a salary. This class you must write, such that:
You write the standard default and specifying constructors, which utilize the base Person classes default and specifying constructors respectively.
You write the standard accessor and mutator.
You override Persons toString method.
School.java A very simple class which models some of the functionality of a school. Pay close attention as to how the sole principle and the various students are incorporated - which is composition? - which is aggregation? This class is complete and must not be modified.
SchoolDriver.java A simple driver class to test all of the above classes. This class you must write, such that:
You construct two different schools.
You construct and add a different student to each school.
You construct one additional student, and add them to both schools.
You produce output that is at least functionally equivalent to the following:
Schools Name: Somewhere East
Principles Name: John Hawlks - $35000.0 Yearly Jimmy - GPA - 3.5
Jenny - GPA - 3.8
Schools Name: Somewhere West
Principles Name: Amy Hope - $48000.0 Yearly Jenny - GPA - 3.8
Billy - GPA - 3.8 Person: public class Person { private String name; public Person() { this(""); } public Person(String name) { this.setName(name); } private void setName(String name) { this.name = name; } public String getName() { return this.name; } public String toString() { return this.getName(); } }
School:
import java.util.ArrayList;
public class School { private String name; private Principle principle; private ArrayList students; public School() { this("", "", 0.0); } public School(String sName, String pName, double salary) { this.setName(sName); this.principle = new Principle(pName, salary); this.students = new ArrayList(); } private void setName(String name) { this.name = name; } public String getName() { return this.name; } public void addStudent(Student student) { this.students.add(student); } public void schoolAudit() { System.out.println("School\'s Name: " + this.getName()); System.out.println("\tPrinciple\'s Name: " + this.principle.toString()); for ( Student student : students ) System.out.println("\t\t" + student.toString()); } }
Student:
public class Student extends Person { private double gpa; public Student() { super(); this.setGPA(0); }
public Student(String name, double gpa) { super(name); this.setGPA(gpa); } private void setGPA(double gpa) { this.gpa = gpa; } public double getGPA() { return this.gpa; } public String toString() { return super.toString() + " - GPA - " + this.getGPA(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started