Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CODE IN JAVA UML diagram: > Comparable 1 > Gym Member getName() getMemberNumbero setMemberNumber FitnessCentre name members displayMembers C. has members > Person A. name
CODE IN JAVA
UML diagram: > Comparable 1 > Gym Member getName() getMemberNumbero setMemberNumber FitnessCentre name members displayMembers C. has members > Person A. name getName() toStringo > Student Instructor B. studentNum facultyID rank 1 teaches * Course taught by course Number courseName enrolls in has displayClassListo Graduate Undergraduate major supervisor PART A: Hierarchies and abstract classes 1. Create the hierarchical class structure shown in the UML diagram annotated as A. This part includes the Person, Student, Instructor, Undergraduate and Graduate classes. Person and Student are abstract classes. 2. In a driver class called As3_Driver.java instantiate the following objects: Name Student # 777 Object Type Undergraduate Undergraduate Object Type Graduate Graduate Harry Potter Draco Malfoy Name Marcus Flynt Percy Weasley 301 Student # 111 128 Major Biopsychology Chemistry Supervisor Severus Snape Minerva McGonigal Rank Professor Faculty ID Object Type Instructor 456 Name Minerva McGonigal Severus Snape Instructor 666 Assistant Professor a. Add all of the above objects to an ArrayList of Persons b. Use 5 different for statements to print the lists of persons, students, instructors, undergraduates, and graduates. Example: Students: Harry Potter Draco Malfoy Marcus Flynt Percy Weasley Graduate students: Marcus Flynt Percy Weasley Undergraduate students: Harry Potter Draco Malfoy ... etc. PART B: Associations Continue building the Java program from Part A to add the course class. 1. Implement the associations in the following manner: a. Add the necessary class fields in classes Course, Instructor and Student. Be mindful of the type of association (1...*, *...*, etc.) when creating these fields. b. Implement an addCourse () method in the Student class that adds a course to the students list of courses. When a student adds a course, the course's class list is also updated by adding that student in it. c. Implement an assignInstructor() method to the course class that assigns an instructor to the course. When an instructor is assigned to a course, the course is also added to their teaching list. 2. In the driver class a. Instantiates 2 courses: Course Number ACS-2947 ACS-3916 Course Name Data Structures and Incantations Wizard-Computer Interaction b. Add instructors to the courses: use the assignInstructor () method of the Course class: Course ACS-2947 ACS-3916 Instructor Name Severus Snape Minerva McGonigal C. Use the addCourse () method from the Student class to add the courses to each student as per the following table: Course ACS-2947 ACS-2947 ACS-2947 ACS-3916 Student Name Harry Potter Draco Malfoy Marcus Flynt Draco Malfoy StudentNum 777 301 111 301 128 ACS-3916 ACS-3916 Percy Weasley Harry Potter 777 d. Implement the displayClassList() method in the course class that prints the list of students in the following manner: ACS-2947 Data Structures and Incantations Instructor: Severus Snape Student# Name status 777 Harry Potter Undergraduate 301 Draco Malfoy Undergraduate 111 Marcus Flynt Graduate PART C: Interfaces Continue to develop the program from Part B to include the membership to the university's fitness facility. 1. Create the GymMember interface as per the UML diagram. a. Make the necessary changes to the Person class so that it implements the GymMember interface and Person objects can become members of the gym. You may have to add another field in the Person class to store the gym member number. Set the gym member number to -1 by default in the constructor. b. Have GymMember extend comparable so that the natural ordering of members is alphabetically by name. i. You will need to implement compare to in the Person class with a GymMember parameter. ii. Note that the Person class itself does not implement Comparable. 2. Add FitnessFacility class as per the UML diagram. a. Add the necessary features suggested for FitnessFacility such as a name, a method addMember() to add members to the facility, and a method to display the names of its members. Include necessary getters, setters, and constructors. b. Include a static variable lastNumber that is used to assign memberNumbers to new members. When a member is added using addMember (), check if a gym member number is assigned already (hint: remember that we had -1 as a default number which essentially means that the number is not assigned). If a member number is not assigned, set the member number of the GymMember being added using lastNumber and increment it for the next use. c. Include a displayMembers () method that prints the name and member list of the facility as given in the sample output below. Sample output: Facility Name: The Dungeon Member# Name 1002 Draco Malfoy 1001 Harry Potter 1003 Marcus Flynt 1000 Minerva McGonigal In the driver program Create an instance of FitnessFacility with the name The Dungeon. Add Draco Malfoy, Harry Potter, Marcus Flynt, Minerva McGonigal as the members. Displays the list of gym members. UML diagram: > Comparable 1 > Gym Member getName() getMemberNumbero setMemberNumber FitnessCentre name members displayMembers C. has members > Person A. name getName() toStringo > Student Instructor B. studentNum facultyID rank 1 teaches * Course taught by course Number courseName enrolls in has displayClassListo Graduate Undergraduate major supervisor PART A: Hierarchies and abstract classes 1. Create the hierarchical class structure shown in the UML diagram annotated as A. This part includes the Person, Student, Instructor, Undergraduate and Graduate classes. Person and Student are abstract classes. 2. In a driver class called As3_Driver.java instantiate the following objects: Name Student # 777 Object Type Undergraduate Undergraduate Object Type Graduate Graduate Harry Potter Draco Malfoy Name Marcus Flynt Percy Weasley 301 Student # 111 128 Major Biopsychology Chemistry Supervisor Severus Snape Minerva McGonigal Rank Professor Faculty ID Object Type Instructor 456 Name Minerva McGonigal Severus Snape Instructor 666 Assistant Professor a. Add all of the above objects to an ArrayList of Persons b. Use 5 different for statements to print the lists of persons, students, instructors, undergraduates, and graduates. Example: Students: Harry Potter Draco Malfoy Marcus Flynt Percy Weasley Graduate students: Marcus Flynt Percy Weasley Undergraduate students: Harry Potter Draco Malfoy ... etc. PART B: Associations Continue building the Java program from Part A to add the course class. 1. Implement the associations in the following manner: a. Add the necessary class fields in classes Course, Instructor and Student. Be mindful of the type of association (1...*, *...*, etc.) when creating these fields. b. Implement an addCourse () method in the Student class that adds a course to the students list of courses. When a student adds a course, the course's class list is also updated by adding that student in it. c. Implement an assignInstructor() method to the course class that assigns an instructor to the course. When an instructor is assigned to a course, the course is also added to their teaching list. 2. In the driver class a. Instantiates 2 courses: Course Number ACS-2947 ACS-3916 Course Name Data Structures and Incantations Wizard-Computer Interaction b. Add instructors to the courses: use the assignInstructor () method of the Course class: Course ACS-2947 ACS-3916 Instructor Name Severus Snape Minerva McGonigal C. Use the addCourse () method from the Student class to add the courses to each student as per the following table: Course ACS-2947 ACS-2947 ACS-2947 ACS-3916 Student Name Harry Potter Draco Malfoy Marcus Flynt Draco Malfoy StudentNum 777 301 111 301 128 ACS-3916 ACS-3916 Percy Weasley Harry Potter 777 d. Implement the displayClassList() method in the course class that prints the list of students in the following manner: ACS-2947 Data Structures and Incantations Instructor: Severus Snape Student# Name status 777 Harry Potter Undergraduate 301 Draco Malfoy Undergraduate 111 Marcus Flynt Graduate PART C: Interfaces Continue to develop the program from Part B to include the membership to the university's fitness facility. 1. Create the GymMember interface as per the UML diagram. a. Make the necessary changes to the Person class so that it implements the GymMember interface and Person objects can become members of the gym. You may have to add another field in the Person class to store the gym member number. Set the gym member number to -1 by default in the constructor. b. Have GymMember extend comparable so that the natural ordering of members is alphabetically by name. i. You will need to implement compare to in the Person class with a GymMember parameter. ii. Note that the Person class itself does not implement Comparable. 2. Add FitnessFacility class as per the UML diagram. a. Add the necessary features suggested for FitnessFacility such as a name, a method addMember() to add members to the facility, and a method to display the names of its members. Include necessary getters, setters, and constructors. b. Include a static variable lastNumber that is used to assign memberNumbers to new members. When a member is added using addMember (), check if a gym member number is assigned already (hint: remember that we had -1 as a default number which essentially means that the number is not assigned). If a member number is not assigned, set the member number of the GymMember being added using lastNumber and increment it for the next use. c. Include a displayMembers () method that prints the name and member list of the facility as given in the sample output below. Sample output: Facility Name: The Dungeon Member# Name 1002 Draco Malfoy 1001 Harry Potter 1003 Marcus Flynt 1000 Minerva McGonigal In the driver program Create an instance of FitnessFacility with the name The Dungeon. Add Draco Malfoy, Harry Potter, Marcus Flynt, Minerva McGonigal as the members. Displays the list of gym members
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