Question: in java please. i have already added method 'isSameCourse' which i believe is correct. ~Task 2.7 We can store our own objects in collections. Take




~Task 2.7 We can store our own objects in collections. Take a look at Course.java and Student.java. They are mostly the same as Lab 1's Course and Student classes. Right now, our methods addCourse() and removeCourse() in Student.java do not work very well. There is no checking for duplicates in addCourse(), and removeCourse() only removes based on the object reference. We need courses to be uniquely identifiable based on their code . That requires that the addCourse() method check that there are no courses with identical codes already in the ArrayList before performing the addition. Likewise, removeCourse() should remove the course with the given course code if it exists in the ArrayList. Your task: 1. Define a new method in Course.java called isSameCourse(). This method should: . Take a Course object as the only parameter. Return a boolean true if the supplied Course object's code is equal to this' object's code. false otherwise. 2. Modify the addCourse() method in Student.java so that the addition is only performed if the Student's courses do not already contain a Course with the same code of the supplied Course. This check is in addition to the already implemented checks on fullLoad (1.e. a Student still cannot take more than 5 courses). 3. Modify the removeCourse() method in Student.java so that if a Course with the same code as the supplied Course exists in courses, it is removed. You can assume that all of the Student's Courses have different codes. This is a reasonable assumption if you implemented addCourse() correctly! fullLoad should still be modified accordingly: if a remove is performed the fullLoad field should be set to false. Course Java Student.java import java.util.ArrayList; public class Student private String name; private String id; private ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
