Question: Students can take a specific course if they complete all the prerequisite courses of that specific course. Students each have a name, a student ID,

Students can take a specific course if they complete all the prerequisite courses of that specific course. Students each have a name, a student ID, number of credits completed, number of credits completed, courses completed and courses taken these fields. We provide one class TestStudent. Now write the source codes of class Course and class Student so that the given classes work. Implementing class Course The skeleton that we have provided is missing the implementation of the methods. Fill in the body of the methods with the appropriate code. You can add any number of instance variables as you wish. Implementing class Student You will need to define and implement the missing methods of class Student. Read the main method of class TestStudent and investigate the compile-time errors to figure out what methods are missing. You can add any number of instance variables as you wish. Notes: While implementing addCourse() method, keep in mind you can only add those courses for which a student has completed all its prerequisite courses, e.g. you can add course CSE106 only if a student has completed its pre-requisite course CSE103 Classes public class Course { String name; String identifier; double credit; Course[] prerequisite; Course(String identifier, double credit){ //implement this method } Course(String name, String identifier, double credit){ //implement this method } public void setPrerequisite(Course c){ //implement this method } public void setPrerequisite(Course[] c){ //implement this method }

public String toString(){ //implement this method } } public class Student { String name; String studentID; Course[] coursesCompleted; double creditsCompleted; Course[] coursesTaken; double creditsTaken; //Implement the methods } public class TestStudent { public static void main(String[] args) { Course c1 = new Course("CSE103", 4.5); Course c2 = new Course("CSE106", 3.0); Course c3 = new Course("Object Oriented Programming Language", "CSE110",

4.5); Course c4 = new Course("CSE207", 4.5); Course c5 = new Course("Algorithms", "CSE246", 4.5); Course[] pre1 = {c2, c3}; Course[] pre2 = {c2, c4}; c2.setPrerequisite(c1); c3.setPrerequisite(c2); c4.setPrerequisite(pre1); c5.setPrerequisite(pre2); System.out.println(c1); System.out.println(c2); System.out.println(c3); System.out.println(c4); System.out.println(c5); Student s1 = new Student("Harry", "3012-3-60-111"); System.out.println(s1); s1.addCourse(c2); Course[] completed = {c1, c2, c3}; s1.setCoursesCompleted(completed); s1.addCourse(c4); System.out.println(s1); } }

Output Output of TestStudent CSE103: null, Credit: 4.5 Prerequisite: CSE106: null, Credit: 3.0 Prerequisite: CSE103 CSE110: Object Oriented Programming Language, Credit: 4.5 Prerequisite: CSE106 CSE207: null, Credit: 4.5 Prerequisite: CSE106, CSE110 CSE246: Algorithms, Credit: 4.5 Prerequisite: CSE106, CSE207 Name: Harry Credits Completed: 0.0 Credits Taken: 0.0 Could not add course CSE106 Course CSE207 added successfully Name: Harry Credits Completed: 12.0 Credits Taken: 3.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!