Question: Change assignNewCourse() to do : - method should add the new Course to the courses field, but cannot assign the Course if the instructor is
Change assignNewCourse() to do :
- method should add the new Course to the courses field, but cannot assign the Course if the instructor is already assigned to the Course
- if the Course is aasigned, it should take all the students enrolled in the course and add them to the students ArrayList in the instructor class
- cannot be assigned if total course students is over 500, use a boolean to return whether successful or not
- if successful, set the instructor field for the Course to that Instructor.
- getNumStudents() to return the nunber of students the instructor has

import java.util.ArrayList; public class Instructor { private String name; private String department; private boolean tenure; private ArrayList courses = new ArrayListo; private ArrayList numStudents= new ArrayList(); public Instructor(String name, String department, boolean tenure) { this.name = name; this.department - department; this.tenure = tenure; } public String getName() { return name; } public String getDepartment() { return department; } ca public boolean getTenure() { return tenure; } D public ArrayList getNumStudents() { return numStudents; } public void setTenure(boolean newValue) { tenure = newValue; } public boolean assignNewCourse(Course course) { (!course. isSameCourse (course)) { } I numStudents += numllenStudents; return true; } import java.util.ArrayList; public class course { o 7 private final String title; // title of the course private final String code; 11 course code private ArrayList enrolledstudents = new ArrayList(); // private String instructor = 1; // the name of the instructor o 9 10 13 e * Creates a new course with the supplied attributes. The number of students is */ public Course(String title, String code) { this.title = title; this.code = code; } 15 16 17 18 19 20 21 22 23 24 25 26 public boolean 1sSameCourse(Course course) (course.equals(code)) { 50) return true; } return false; } /* * Get this course's code. / public String getCode() { return code; } 20 30 Get this course's titte. public String getTitle() { return title; 38 / Increments the number of enrolled students. / public void adden Student (student student) 49 2