a) Write a method in the Department class called offerCourse (Course course) that adds the given...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <Student>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<Course> courseList; // all courses offered by the department 8 private Vector<Student> 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 } } 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 <Student>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<Course> courseList; // all courses offered by the department 8 private Vector<Student> 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 } }
Expert Answer:
Answer rating: 100% (QA)
Question a Using the add method to add the given course to the department Departmentja... View the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these accounting questions
-
Write a method in the HashIntSet class called toString that returns a string representation of the elements in the set, such as "[-2, 3, 5, 6, 8]". The order of the elements in the string does not...
-
Write a method in the HeapIntPriorityQueue class called toString that returns a string representation of the elements in the queue, such as "[42, 50, 45, 78, 61]". The order of the elements in the...
-
Write a method in the HashIntSet class called toArray that returns the elements of the set as a filled array. The order of the elements in the array is not important as long as all elements from the...
-
The use of prenumbered checks in disbursing cash is an application of the principle of: (a) establishment of responsibility. (b) segregation of duties. (c) physical controls. (d) documentation...
-
Wuttke Corp. wants to raise $5,375,000 via a rights offering. The company currently has 950,000 shares of common stock outstanding that sell for $55 per share. Its underwriter has set a subscription...
-
What requirements do professional sport leagues use to try to ensure athlete representatives are competent and professional in their representation of athletes?
-
Current generally accepted accounting principles require that the discount rate for calculating the present value of future postretirement health care benefits be based on: a. The current rate of...
-
Refer to the data in Solved Problem 14-1, which deals with Higgins Plumbing and Heating. Higgins has now collected 100 weeks of data and finds the following distribution for sales: HOT WATER NUMBER...
-
When Patey Pontoons issued 4% bonds on January 1, 2024, with a face amount of $520,000, the market yield for bonds of similar risk and maturity was 5%. The bonds mature December 31, 2027 (4 years)....
-
Beale Management has a noncontributory, defined benefit pension plan. On December 31, 2021 (the end of Beale's fiscal year), the following pension-related data were available: Projected Benefit...
-
Bulk orders A company uses an item of inventory as follows Purchase price Annual demand Ordering cost Annual holding cost $96 per unit 4,000 units $300 10% of purchase price Economic order quality...
-
What is the value of number after the following statements execute? int number = 10; number 5; number -= 2; number *= 3;
-
0.056kg tennis ball is thrown straight up at a speed of 20/ms A. What is the ball's kinetic energy when it is thrown? B. What must be the ball's potential energy be when it reaches the top? C. How...
-
Given a CPU with the following specs: Uses 10 V Requires 49 W Has a clock rate of 13 Hz What is the capacitance? Round your answer to 2 decimal places
-
Determine the time complexity of the following algorithm, where n is the input size. (4 points) sum = 0 i = 1 for 1 to n do sum* = i end for j = i while <10 do j += 1 sum += j *= 2 end while
-
ABC Limited, is an exporter from UK. His receivables on account of exports to Canada are Can $ 5,00,000 which are due in 6 months. ABC wants to hedge is export receivable in Forward Market. The...
-
City Hospital was losing money, and the hospital's executive director knew action had to be taken to reduce expenditure. Since a major portion of the costs were labour-related, the choice was...
-
The baseball player A hits the ball from a height of 3.36 ft with an initial velocity of 34.8 ft/s. 0.14 seconds after the ball is hit, player B who is standing 15 ft away from home plate begins to...
-
Consider writing a program to be used to manage a collection of movies. There are three kinds of movies in the collection: dramas, comedies, and documentaries. The collector would like to keep track...
-
Write a method called evenLevels that makes sure that all branches end on an even level. If a leaf node is on an odd level it should be removed from the tree. We will define the root as being on...
-
Using Boolean Zen, write an improved version of the following method, which returns whether the given String starts and ends with the same character: public static boolean startEndSame (String str) {...
-
Which of the following are boiler mountings ? (a) Economiser (b) Fusible plug (c) Super heater (d) Injector
-
Which out of the following boiler is capable of generating superheated steam without additional accessories ? (a) Cochran (b) Lancashire (c) Locomotive (d) Cornish
-
The economiser of the boiler plant is used mainly to (a) increase steam capacity (b) reduce fuel consumption (c) increase steam pressure (d) increase life of the boiler
Study smarter with the SolutionInn App