Question
NEED TO BE SOLVE IN JAVA!!! PROBLEM 3: Course Correction [40 points] Now that we have that sorted, we are ready to connect all the
NEED TO BE SOLVE IN JAVA!!!
PROBLEM 3: Course Correction [40 points] Now that we have that sorted, we are ready to connect all the dots. You will complete the Course class in this problem. All the information you should need can be found within the descriptions and UML diagram below. The Course class The Course class makes use of all of the other classes that you have made so far. In order to start this problem, you must have completed the first two problems successfully. You may then copy those files over here. Course -courseID: int -courseCode: String -courseName: String -courseCapacity: int -numberStudents: int -room: Room -students: Student[] -waitListCount: int +Course(ID: int, code: String, name: String, room: Room) +getBuildingName(): String +getCampus(): String +getCourseID(): int +getCourseCode(): String +getNumberStudents(): int +getStudents(): Student[] (Returns array of registered students) +isInCourseAlready(student: Student): boolean +isSpaceLeftInCourse(): boolean +registerStudent(student: Student): int +toString(): String Description of methods for the Course class: +Course(ID: int, code: String, name: String, room: Room) Constructs a Course object with course ID, course name and room specified. Number of students and wait list count is cleared. Course capacity is set to the capacity of the room specified. Student array is set initialized to fit capacity. +getBuildingName(): String Returns the name of the building (based on the room) in which the course is located. +getCampus(): String Returns the name of the campus (based on the room) in which the course is located. 7 +getCourseID(): int Returns the ID of the course (e.g. the CRN for your courses) +getCourseCode(): String Returns the course code (e.g. CSCI 1110) +getNumberStudents(): int Returns the number of students registered for the course. +getStudents(): Student[] Returns an array of Students that are registered in the course. Note that this is a subarray of the students array. +isInCourseAlready(student: Student): boolean Returns true if student is already registered for the course, false otherwise. +isSpaceLeftInCourse(): boolean Returns true if there is space left in the course (e.g. number of students is less than the course capacity). +registerStudent(student: Student): int Registers (adds) a Student to the class if possible. If the student is already in the course, the student is not added. If number of students in class is greater than the capacity of the room/course, the student is not added and the wait list count for the course by 1 (student's number on wait list). Returns 0 if student is added to course, -1 if previously registered, or the number on the wait list if there was no space in the course and they were added to the wait list +toString(): String Overrides the existing string representation of the object. Return the following value: value = "COURSE " + course-ID + ": " + course-code + " - " + course-name + " " + room.toString() + " " + "Current: " + number-students + " / " + course-capacity + " " + "Wait list count: " + wait-list-count ;
PROBLEM 1: Student Success [30 points] For this first problem, you will implement a simple class: the Student class! All the information you should need can be found within the description of the Student class (to be created in the file Student.java) and in the UML diagram below. The Student class We always try to put students first! And now we are asking you to as well! Here you will construct the Student class based on the information below. Student -studentID: int -firstName: String -preferredName: String -lastName: String +Student (ID: int, firstName: String, lastName: String) +getStudentId(): int +getName(): String +setLastName (lastName: String): void +set PreferredName (preferredName: String): void +toString(): String Description of methods from the Student class: +Student (ID: int, firstName: String, lastName: String) Constructs a student with designated student ID, first name and last name. Preferred name is initially set to be the same as their first name. +getstudentId(): int Returns the integer student ID. +getName(): String Returns a string containing the student's preferred name in the form: "preferred-name last-name" +setLastName (lastName: String): void Update the last name of a student. +setPreferredName (preferredName: String): void Sets the name that the student would preferred to be called. +toString(): String Overrides the existing string representation of the object to be: getName() + " (" + student-id + ")" PROBLEM 2: Room for More [30 points] Now that you've got the students sorted, you need to give them a room to study in. The next task is to finish off the Building and Room classes based on the UML diagrams and descriptions below. The Building class The Building class is pretty straight forward as you can see below. You can tackle this even before you're finished with your Student class in problem 1. Building -buildingName: String -numberFloors: int -campusLocation: String +Building (name: String, floors: int, campus: String) +getBuildingName(): String +getCampus (): String +hasMoreFloors (otherBuilding: Building): int +toString(): String Description of methods from the Building class: +Building (name: String, floors: int, campus: String) Constructs a building with building name, number of floors and located on the specified campus name. +getBuildingName(): String Returns the building name. +getCampus (): String Returns a campus that a building is located on. +hasMoreFloors (otherBuilding: Building): int. Compares the number of floors that the building has to another Building object. It returns the number of floors that it has more than the other one. If taller, the number is positive (i.e. returning 3 implies that it has more floors that then "other building"). If equal, the two buildings are of the same height. If negative, the other building is the taller of the two. +toString(): String Overrides the existing string representation of the object to be: building-name + " building (" + num-floors + " floors), " + campus + " campus" The Room class The Room class relies on the Building class as previously created. Room -building: Building -roomNumber: int -roomCapacity: int +Room (building: Building, room: int, capacity: int) +getBuilding(): Building +getRoomCapacity (): int +setRoomCapacity (capacity: int): void +toString(): String Description of methods for the Room class: +Room (building: Building, room: int, capacity: int) Constructs a room in the designated Building, and with the specified room number and capacity. +getBuilding(): Building Returns the building in which the room is located. Description of methods for the Room class: +Room (building: Building, room: int, capacity: int) Constructs a room in the designated Building, and with the specified room number and capacity. +getBuilding () : Building Returns the building in which the room is located. +getRoomCapacity(): int Returns the integer room capacity +setRoomCapacity (capacity: int): void | Sets a new capacity for a room (e.g. if the room was expanded during a remodel). +toString(): String Overrides the existing string representation of the object to be: building-name + " building, Room " + roomNumber + " (seats " + capacity + ")" PROBLEM 3: Course Correction [40 points] Now that we have that sorted, we are ready to connect all the dots. You will complete the Course class in this problem. All the information you should need can be found within the descriptions and UML diagram below. The Course class The Course class makes use of all of the other classes that you have made so far. In order to start this problem, you must have completed the first two problems successfully. You may then copy those files over here. Course -courseID: int -courseCode: String -courseName: String -courseCapacity: int -numberStudents: int -room: Room -students: Student[] -waitListCount: int +Course (ID: int, code: String, name: String, room: Room) +getBuildingName(): String +getCampus (): String +getCourseID(): int +getCourseCode (): String +getNumberStudents(): int +getstudents(): Student[] (Returns array of registered students) +isInCourseAlready (student: Student): boolean +isSpaceLeftInCourse(): boolean +registerstudent (student: Student): int +toString(): String Description of methods for the Course class: +Course (ID: int, code: String, name: String, room: Room) Constructs a Course object with Course ID, Course name and room specified. Number of students and wait list count is cleared. Course capacity is set to the capacity of the room specified. Student array is set initialized to fit capacity. +getBuildingName(): String Returns the name of the building (based on the room) in which the course is located. +getCampus(): String Returns the name of the campus (based on the room) in which the course is located. +getCourseID(): int Returns the ID of the course (e.g. the CRN for your courses) +getCourseCode () : String Returns the course code (e.g. "CSCI 1110") +getNumberStudents(): int Returns the number of students registered for the course. +getStudents(): Student[] Returns an array of Students that are registered in the course. Note that this is a subarray of the students array. +isInCourseAlready (student: Student): boolean Returns true if student is already registered for the course, false otherwise. +isSpaceLeftInCourse (): boolean Returns true if there is space left in the course (e.g. number of students is less than the course capacity). +registerstudent (student: Student); int Registers (adds) a Student to the class if possible. If the student is already in the course, the student is not added. If number of students in class is greater than the capacity of the room/course, the student is not added and the wait list count for the course by 1 (student's number on wait list). Returns O if student is added to course, -1 if previously registered, or the number on the wait list if there was no space in the course and they were added to the wait list +toString(): String Overrides the existing string representation of the object. Return the following value: value = "COURSE" + course-ID + ": " + course-code + "-" + course-name + " " + room.toString() + " ". + "Current:" + number-students +"/" + course-capacity + " " + "Wait list count:" + wait-list-countStep 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