Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Part 3 subpackage p3 under the hw1 package and copy here the Course, Grizzly, Student and Hw1Test classes from subpackage p2. In the

image text in transcribed

Create a Part 3 subpackage p3 under the hw1 package and copy here the Course, Grizzly, Student and Hw1Test classes from subpackage p2. In the p3 subpackage, create a public class named Instructor as a subclass of the Grizzly class, and add the following private data field to the Instructor class: - courses, which is an Array List of Course objects each representing a course the instructor teaches. Create the following methods in the Instructor class in the p3 subpackage: - A constructor public Instructor (String name) that uses the constructor of the Grizzly superclass to create a Grizzly object with the given name, and initializes the courses field to an empty list. - A tostring() method that returns a string of the format Instructor {1d: _ nane: __ courses: where the underscores after "id: " and "name: " should be replaced with the values of the respective fields, and that after "courses: " should be replaced with a list consisting only of the names of the courses the instructor is teaching. In the Course class in the p3 subpackage: - Add a private data field named instructor which is an object of the Instructor class that represents the instructor of the course. - Add getter and setter for the instructor field. - Change the tostring method so that it returns a string of the format Course\{nane: _, instructor: _ _ capacity: _ roster: _ } _ 7 where the underscore after "instructor: should be replaced with the name of the instructor field if it is not null. Otherwise (i.e., if the instructor has not been assigned), then use "TBO" for the name. In the Instructor class, add a method public void teachCourse (Course course) that assigns this Instructor object to the instructor field of the Course object in the argument, and adds the given course to the courses field of this Instructor object. Run the main method of the Hw1Test class in the p3 subpackage. You should see Add the following code to the end of the main method of the Hw1Test class in the p3 subpackage: - Create two Instructor objects whose names are Evelyn and Richard, respectively. Print the two Instructor objects. - Have Evelyn teach ITEC 4320 and ITEC 4700 , and have Richard teach ITEC 4860 . - Print the two Instructor objects. Your code should print Instructorfid: 5, name: Evelym, courses: [ITEC 4320, ITEC 4700]) Instructorfid: 6, name: Richard, courses: [ITEC 4360]) - Print the three Course objects. Your code should print Courseiname: ITEC 4320, instructor: Evelyn, capacity: 3, roster: [Carol, Daniel, Bob]] Course-name: ITEC 4700, instructor: Evelyn, capacity: 3, roster: [Alice, Bob, Daniel]? Course-name: ITEC 4260, instructar: Richard, capacity: 3, roster: [Carol, Daniel, Alice]\}

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

ISBN: 0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

Identify cultural barriers to communication.

Answered: 1 week ago