Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
image text in transcribed
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

What is data visualisation?

Answered: 1 week ago

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

2. To compare the costs of alternative training programs.

Answered: 1 week ago

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago