Question
Design and Implement a Multiclass Program A course registration program The requirements for the course registration program are stated as follows: Each course has a
Design and Implement a Multiclass Program
A course registration program
The requirements for the course registration program are stated as follows:
Each course has a number, name and can have between 1 to 15 course sections. Course sections can be added/removed to/from the course as required. The program keeps track of the number of courses.
Each course section belongs to one and only one course, and has a course registration number (CRN), a section number, and can have between 8 to 30 students and 1 to 3instructors. Students and instructors can be added/dropped to/from the course section as required.
An instructor can teach between 1 to 4 course sections. The ID number, name, department and hired date of each instructor is stored.
A student can register between 1 to 5 course sections. The ID number, name, major and admission date of each student is stored.
There is a one to one association between an instructor and the hired date. There is also a one to one association between a student and the admission date.
Each course section belongs to one and only one course, and has a course registration number (CRN), a section number, and can have between 8 to 30 students and 1 to 3instructors. Students and instructors can be added/dropped to/from the course section as required.
An instructor can teach between 1 to 4 course sections. The ID number, name, department and hired date of each instructor is stored.
A student can register between 1 to 5 course sections. The ID number, name, major and admission date of each student is stored.
There is a one to one association between an instructor and the hired date. There is also a one to one association between a student and the admission date.
Composition: is a specific type of aggregation in which the existence of one class (or object) depends on the existence of another class of object.
In UML a composition is specified with a solid diamond.
Aggregation and composition are both types of associations.
An Association describes a specific relationship between two classes (or objects) that defines the
activity between the classes (or objects). For example, an instructor teaches a course, or a student
registers for a course.
Course |
|
-courseNumber: String -courseName: String -courseSections: ArrayList -MIN_NUMBER_OF_COURSESECTIONS=1 -MAX_NUMBER_OF_COURSESECTIONS=15 -numberOfCourses:int | Default Default Default ArrayList of capacity 15
Default 0 |
+Course() +Course(courseNumber: String, courseName:String) | Creates a default course object Creates a course object with the given courseNumber and courseName |
Design and Implement a Multiclass Program
A course registration program
UML
Course |
|
-courseNumber: java.lang.String -courseName: java.lang.String -numberOfCourses: int -courseSections:java.util.ArrayList +MIN_NUMBER_OF_COURSE_SECTIONS: int = 1 +MAX_NUMBER_OF_COURSE_SECTIONS: int = 15
| Default Default Default 0 Default capacity 15 Course Sections |
+Course()
+Course(courseNumber:String, courseName:String)
+getCourseNumber(): java.lang.String +getCourseName(): java.lang.String +toString():java.lang.String
+getNumberOfCourses(): int +addCourseSection(courseSection: CourseSection): Boolean
+removeCourseSection(courseSection:CourseSection): boolean
+purge():void | Creates a default Course with the default values specified. Increases numberOfcourses by 1 Creates a Course with the given parameters and an ArrayList of CourseSection of default capacity. IncreasesnumberOfcourses by 1
Returns the String representation of the object. Include courseNumber, courseName, courseSections
Adds a CourseSection to the ArrayList and returns true if it is successfully added, false if the ArrayList is at full capacity Removes a CourseSection from the ArrayList and returns true if it is successful, false if the ArrayList does not contain the specified CourseSection Removes CourseSections that have less than 8 students from all relevant ArrayLists |
CourseSection |
|
-cRN: int -courseSectionNumber: int -instructors: java.util.ArrayList -students: java.util.ArrayList +MIN_NUMBER_OF_INSTRUCTORS:int = 1 +MAX_NUMBER_OF_INSTRUCTORS:int = 3 +MIN_NUMBER_OF_STUDENTS: int= 8 +MAX_NUMBER_OF_STUDENTS: int= 30 | Default 0 Default 0 Default capacity 3 Default capacity 30 |
+CourseSection() +CourseSection(cRN:int,courseSectionNumber:int)
+getCRN():int +getCourseSectionNumber():int getInstructors():java.util.ArrayList getStudents():java.util.ArrayList +toString():java.lang.String
+addInstructor(instructor: Instructor):boolean
+dropInstructor(instructor: Instructor): boolean
+addStudent(student: Student):boolean
+dropStudent(student: Student):boolean
| Creates a default CourseSection Creates a CourseSection with the given CRN and course section number and creates an ArrayList of Instructor of default capacity and an ArrayList of Student of default capacity
Returns a String representation of the object. Include the cRN, courseSectionNumber, instructors and students Adds an instructor to the course section and returns true if successful, returns false if the instructor cannot be added if the capacity of the ArrayList is reached Drops an instructor from the course section and returns true if successful, returns false if the instructor is not in the ArrayList Adds a student to the course section and returns true if successful, returns false if the students cannot be added if the capacity of the ArrayList is reached Drops a student from the course section and returns true if successful, returns false if the students is not in the ArrayList |
Instructor |
|
-instructorIDNumber: int -instructorName: java.lang.String -instructorDepartment: java.lang.String -hiredDate: java.util.Date -courseSectionsTaught: java.util.ArrayList +MIN_NUMBER_OF_COURSES_TAUGHT :int = 1 +MAX_NUMBER_OF_COURSES_TAUGHT :int = 4
| Default 0 Default Default Default null Default capacity of ArrayList is 4 |
+Instructor() +Instructor(instructorIDNumber: int, instructorName: java.lang.String,instructorDepartment: java.lang.String)
+getInstructorIDNumber ():int +getInstructorName():String +getInstructorDepartment():String getCourseSectionsTaught():java.util.ArrayList +toString():java.lang.String
| Creates a default Instructor object Creates an Instructor object with the given parameters. Creates a default Date object andArrayList with default capacity
Returns a String representation of the object. Include only the instructorIDNumber,instructorName, instructorDepartment and hiredDate |
Student |
|
-studentIDNumber: int -studentName: java.lang.String -studentMajor: java.lang.String -admissionDate: java.util.Date -courseSectionsRegistered: java.util.ArrayList +MIN_NUMBER_OF_COURSES_REGISTERED :int = 1 +MAX_NUMBER_OF_COURSES_REGISTERED :int = 5
| Default 0 Default Default Default null Default capacity of ArrayList is 5 |
+Student() +Student(studentIDNumber: int, studentName: java.lang.String,studentMajor: java.lang.String)
+getStudentIDNumber ():int +getStudentName():String +getStudentMajor():String getCourseSectionsRegistered():java.util.ArrayList +toString():java.lang.String
| Creates a default Student object Creates a Student object with the given parameters. Creates a default Date object and ArrayListwith default capacity
Returns a String representation of the object. Include only the studentIDNumber, studentName,studentMajor and admissionDate |
Pseudocode for the purge method
Create ArrayList named purgeCourseSections for CourseSection objects to be purged
For-loop to iterate through all CourseSection objects in ArrayList courseSections
Get and store the CourseSection
If the number of students in the CourseSection is less than 8,
Add the CourseSection to ArrayList purgeCourseSections
Get and store the ArrayList instructors from the CourseSection
Get and store the ArrayList students from the CourseSection
For-loop to iterate through all Instructor objects in ArrayList instructors
Get and store the Instructor
Get and store the ArrayList courseSectionsTaught from the Instructor
Remove the CourseSection from the ArrayList
For-loop to iterate through all Student objects in ArrayList students
Get and store the Student
Get and store the ArrayList courseSectionsRegistered from the Student
Remove the CourseSection from the ArrayList
For-loop to iterate through all CourseSection objects in ArrayList purgeCourseSections
Get and store the CourseSection
Remove the CourseSection from the ArrayList courseSections
*
Additional Methods
Include the following methods in the Instructor and Student classes
+addCourseSection(courseSection: CourseSection):boolean
Adds a CourseSection to the ArrayList and returns true if it is successfully added, false if the ArrayList is at full capacity
+dropCourseSection(courseSection: CourseSection):boolean
Removes a CourseSection from the ArrayList and returns true if it is successful, false if the ArrayList does not contain the specified CourseSection
*
TestCourseRegistration Class
Create a class TestCourseRegistration that performs the following tasks:
Creates 1 course with number, and name
Creates 2 course sections with CRN, and number
Creates 11 students and 2 instructors. Name the objects student1, student 2, student3, and student11
Instructor1 and instructor2
Adds the first 10 students and an instructor to the first course section
Adds the first course section to the 10 students and instructor
Adds the first 5 students, the 11th student and the other instructor to the second section
Adds the second course section to the 6 students and other instructor
*
TestCourseRegistration Class
Contd.:
Adds the 2 sections to the course
For the course, display the course number, course name, information for the instructor and students in each section
Display the course sections registered by student1 and the course sections taught by instructor 1
Drop student1 and student5 from the first course section
Drop the course section from the two students
Drop student3 from the second course section
Drop the second course section from the student
For the course, display the course number, course name, information for the instructor and students in each section
*
TestCourseRegistration Class
Contd.:
Display the course sections registered by student1 and the course sections taught by instructor 1
Call the purge method
For the course, display the course number, course name, information for the instructor and students in each section
Display the course sections registered by student1 and the course sections taught by instructor 2
*
View as PageDownloadToggle Fullscreen
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started