Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class Course { private String courseName, grade, semesterName; public Course(String courseName, String grade, String semesterName) { this.courseName = courseName; this.grade = grade; this.semesterName = semesterName;
class Course { private String courseName, grade, semesterName; public Course(String courseName, String grade, String semesterName) { this.courseName = courseName; this.grade = grade; this.semesterName = semesterName; } public String getCourseName() { return courseName; } public void setCourseName(String courseName) { this.courseName = courseName; } public String getGrade() { return grade; } public void setGrade(String grade) { this.grade = grade; } public String getSemesterName() { return semesterName; } public void setSemesterName(String semesterName) { this.semesterName = semesterName; } } class Student { private String name; private static int ID = 0; private double GPA; private Course[] courses; public Student(String name, double GPA, int numCourses) { this.name = name; this.GPA = GPA; courses = new Course[numCourses]; ID ++; } public String getName() { return name; } public void setName(String name) { this.name = name; } public static int getID() { return ID; } public static void setID(int ID) { Student.ID = ID; } public double getGPA() { return GPA; } public void setGPA(double GPA) { this.GPA = GPA; } public Course[] getCourses() { return courses; } public void setCourses(Course[] courses) { this.courses = courses; } } class Department { private String name, chairName; private int numStudents; private Student[] students; public Department(String name, String chairName, int numStudents) { this.name = name; this.chairName = chairName; this.numStudents = numStudents; students = new Student[numStudents]; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getChairName() { return chairName; } public void setChairName(String chairName) { this.chairName = chairName; } public int getNumStudents() { return numStudents; } public void setNumStudents(int numStudents) { this.numStudents = numStudents; } public Student[] getStudents() { return students; } public void setStudents(Student[] students) { this.students = students; } } class College { private String name, deanName; private int numDepartments; private int numStudents; private Department[] departments; public College(String name, String deanName, int numDepartments, int numStudents) { if (numDepartments > 20) { throw new IllegalArgumentException("There can be max of 20 departments in the college!!"); } this.name = name; this.deanName = deanName; this.numDepartments = numDepartments; this.numStudents = numStudents; departments = new Department[numDepartments]; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDeanName() { return deanName; } public void setDeanName(String deanName) { this.deanName = deanName; } public int getNumDepartments() { return numDepartments; } public void setNumDepartments(int numDepartments) { this.numDepartments = numDepartments; } public int getNumStudents() { return numStudents; } public void setNumStudents(int numStudents) { this.numStudents = numStudents; } public Department[] getDepartments() { return departments; } public void setDepartments(Department[] departments) { this.departments = departments; } } class University { private String name, presidentName; private int numColleges, numStudents; private College[] colleges; public University(String name, String presidentName, int numColleges, int numStudents) { if (numColleges > 10) { throw new IllegalArgumentException("There can be max of 10 colleges in the university!!"); } this.name = name; this.presidentName = presidentName; this.numColleges = numColleges; this.numStudents = numStudents; colleges = new College[numColleges]; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPresidentName() { return presidentName; } public void setPresidentName(String presidentName) { this.presidentName = presidentName; } public int getNumColleges() { return numColleges; } public void setNumColleges(int numColleges) { this.numColleges = numColleges; } public int getNumStudents() { return numStudents; } public void setNumStudents(int numStudents) { this.numStudents = numStudents; } public College[] getColleges() { return colleges; } public void setColleges(College[] colleges) { this.colleges = colleges; } }Now, inside main(), write a test code to test the working of your class. The test code should be something like the following: (Note that from the test code, you need to understand what methods each of the above classes should have) public static void main(String[] args) { University pmu = new University("PMU", "Dr. Essa"); pmu.AddCollege("CCES", "Dr. Fadi"); pmu.AddCollege("COE", "Dr. Jamal"); pmu.AddDepartment("CCES", "IT", "Dr. Ghassen");/ote that AddDepartment should be a method in College class. pmu.AddDepartment("CCES", "CE", "Dr. Loay"); pmu.AddDepartment("CCES", "CS", "Dr. Loay"); pmu.AddDepartment("CCES", "SE", "Dr. Ghassen"); pmu.AddDepartment("COE", "Mechanical", "Dr. Nezar"); pmu.AddStudent("Tariq", 201700150, "IT");/ote that AddStudent should be a method in Department class. pmu.AddStudent("Ahmed", 201501110, "CS"); pmu.AddStudent("Hamza", 201645166, "Mechanical"); pmu.AddCourse(201501110, "CSI", "A+", "Spring 2016"); pmu.AddCourse(201700150, "CSII", "B+", "Fall 2017"); /ow, create another university object and fill it with several students. University kfupm = new University(pmu);//copy constructor should create a new university object kfupm.SetName("KFUPM"); kfupm.SetPresentName("Dr. Ahmed"); // now add some colleges, departments, and students in kfupm object. System.out.println(pmu);//it should print the ENTIRE information nicely System.out.println(kfupm); } After creating the above classes, also write the following methods: 1)Find the name of the college which has highest number of students with A or A+ in any of their courses. pmu.FindCollegeWith HighGpaStudents'; 2) Find all the students in the entire university who have GPA>z
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