Question: Create a Part 1 subpackage p1 under the hw1 package. In the p1 subpackage, create a public class named Course, and add the following private

Create a Part 1 subpackage p1 under the hw1 package. In the p1 subpackage, create a public class named Course, and add the following private data fields to the Course class: - name, which is of type String and represents the name of a course. We assume here for simplicity that every course has a unique name that identifies it. - capacity, which is an integer representing the maximum number of students that can enroll in the course. - roster, which is an Array List of strings each representing the name of a student enrolled in the course. Assume here that every student has a distinct name so that a student's name identifies the student. Add the following public methods to the Course class: - A constructor public Course (String name, int capacity) that initializes the name and capacity fields with the values of the arguments, and initializes the roster field to an empty list. Assume here that capacity >0 is satisfied. - A getter for the name field. - Amethod public boolean add (String student) that adds the student in the argument to the roster and returns true if the capacity has not been reached. Otherwise, the method should print an error 1 message "_is full" without adding the student to the roster, where the underscore should be replaced with the name of the course, and return false. - Amethod public void remove (String student) that removes from the roster the student in the argument. You can assume that the student in the argument is a student on the roster. - A tostring! ) method that returns a string, in the default format of Intellid, consisting of the values of all data fields. In the p1 subpackage, create a public class named CourseTest. In the main method of the Account Test class: - Create a Course object named itec2150, using "ITEC 2150" as the course name and 3 as the capacity. Print the itec2150 abject to the console. Your code should print Course { nane = ITEC 2150, capacity =3, roster =[]} - Add "Alice", "Bob", "Carol" and "Daniel" to the itec2150 roster and print the returned results of the add method. Your code should print. - Print the itec2150 object to the console. Your code should print Course\{nane='ITEC 2150, capacity=3, roster =[ Alice, Bob, Carol ]\} - Remove "Bob" from the itec 2150 roster and again add "Daniel" to the roster. Print the itec 2150 object to the console. Your code should print Course { nane = 'ITEC 2150, capacity =3, roster =[ Alice, Carol, Daniel ]} 2 Part 2 Now you will (1) create a Grizzly class and a Student subclass, (2) modify the Course class, and (3) write a class named Hw1Test to test the Grizzly, Student and Course classes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
