Question: a) Write a method in the Department class called offerCourse (Course course) that adds the given course to the department. b) Write a method
a) Write a method in the Department class called offerCourse (Course course) that adds the given course to the department. b) Write a method in the Department class called print CoursesOffered () that displays the list of all courses offered by the department in arbitrary order. It should show all course information (Hint: call the course's tostring() method); c) Write a method in the Student class called registerFor (Course course) that registers a student in the given course. If the student is already registered in the course, then the method does nothing. Otherwise, the appropriate student, Course, and Department objects are updated as necessary. d) Write a method in the Department class called printStudentsByName() that displays a list of all students taking courses in this department. This method should show all student information (Hint: use the Student's toString()). e) Write a method in the Student class called isRegisteredInCourse (Course course) that returns a Boolean value indicating whether or not the given student is registered for any course in this department. f) Write a method in the Department class called isstudent Registered (Student student) that returns the boolean value indicating whether or not the given student is registered for any course in this department. Course.javax Department.java Person.java Student.java 1 public class Course{ 2 private Department dept; 3 private String title; // title of the course (e.g. Intro to programming); 4 private String code; // course code, e.g. SOFE, ELEE, MANE, etc. 5 private int number; // course number, e.g. 1200, 2710, 2800, etc. 6 private Vector classList; // contains all students registered in this course 7 80 public Course(String code, int number, Department dept, String title) { // also initialize the classList; 9 10 11 } 12 13 140 public Course() { // TODO Auto-generated constructor stub // return a string representation of the course with the course code, // name, and number of people registered in the course in the following // format: // SOFE 2710 Object Oriented Programming and Design, Enrollment = 260 return null; 215 16 } 17 4180 public String toString() { 19 20 21 22 23 24 25 26 27 28 29 30 } } Course.java 1 public class Person { 2 Department.java private String name; 4 public Person (String initialName) 50 6 { 7 } 9 100 public Person() 11 { 12 | } 13 14 150 public void setName(String fullName) { 16 17 18 } 190 public String getName() { return null; 20 21 } 22 4230 public String toString() { return null; 24 25 26 } 27 } 234 678 O 8 == THE Person.java X Student.java Course.java Department.java X Person.java Student.java 10 import java.util.HashSet; 2 import java.util. Vector; 3 4 public class Department { 5 private String name; // the name of school Dept of Computing and Info Science 6 private String id; // short name for courses SOFE, ELEE, STAT, etc 97 private Vector courseList; // all courses offered by the department 8 private Vector registerList; // all students taking courses in the department. 9 10 110 public Department (String name, String id) { 12 // also initialize the vectors 13 14 } 15 x160 public String getName() { 17 18 } 19 **200 public String getId() { 21 22 } 23 24 250 public String toString() { 26 // returns a string representation of department name, number 27 // of courses offered and number of students registered in the 28 // department. Use the format: 29 // ECSE: 53 courses, 460 students 30 31 } 32 } Course.java Department.java Person.java Student.java x 1 public class Student extends Person{ 2 private String id; 3 private String name; x 4 private Vector courses; // contains all courses the student is registered in 5 6 70 public Student (String stdName, String stdId) { 8 9 } public String getName() { } public String getId() { } public String toString() { // return a string representation of a student using the following format: // 100234546 John McDonald // Registered courses: ELEE 2110, ELEE 2790, SOFE 2710, SOFE 2800, SOFE 2850 return null; 10 11 A120 13 14 15 160 17 18 19 20 21 22 A230 24 25 26 27 28 29 30 } }
Step by Step Solution
3.48 Rating (161 Votes )
There are 3 Steps involved in it
Question a Using the add method to add the given course to the department Departmentja... View full answer
Get step-by-step solutions from verified subject matter experts
