Question
A sample run would be something like this: - creating a section with max size of 4 students - adding a bunch of students let's
A sample run would be something like this: - creating a section with max size of 4 students - adding a bunch of students let's say: + 441107008, Sultan, 19 -> successful + 441106008, Mohammed, 19 -> successful + 441106008, Mohammed, 19 -> fails (duplicate) + 441105008, Ali, 20 -> successful + 441104008, Mohammed, 21 -> successful + 441103008, Faisal, 21 -> fails (no space) - when we call printList it should print the previous students in that order: + 441107008, Sultan, 19 + 441106008, Mohammed, 19 + 441105008, Ali, 20 + 441104008, Mohammed, 21 - when we call getFirst on Mohammed and display that student it should print the info of student: + 441106008, Mohammed, 19 - when we call getStudents of age younger than 20 and print that array it should show: + 441107008, Sultan, 19 + 441106008, Mohammed, 19 - when we call deleteStudent on id 441105008, and then call printList: + 441107008, Sultan, 19 + 441106008, Mohammed, 19 + 441104008, Mohammed, 21
Good luck!
Student id : int name : String age : int + Student + Student(int, String, int) + setId(int) : void + setName(String) : void setAge(int) : void + getId(): int + getName() : String + getAge(): int + display() : void Section course : String studentList : Student[] nStudents : int + Section(String, int) + searchStudent(int) : int + addStudent(int, String, int) : void + deleteStudents(int) : void + getFirst(String) : Student + getStudents(int) : Student[] printList(): void Class Student Attributes: id: the ID of the student name: the name of the student age: the age of the student . Methods: Student(): default constructor Student(id: int, name: string, age: int): constructor setId(id: int): sets the ID of the student setName(name: string): sets the name of the student setAge(age: int): sets the age of the student getID(): returns the ID of the student getName(): returns the name of the student getAge(): returns the age of the student display(): prints out all the information of the student Class Section: Attributes: . course: the course name of the section studentList: the list of students in the section nStudents: the number of students in the section Methods: Section(course: string, size: int): constructor SearchStudent(id: int): this method should search the list for a student using his id and return the index if he's there or -1 otherwise addStudent(id: int, name: string, age: int): This method should add the student to the section only if there's space and the student isn't already on the list. * deleteStudent (id: int): This method should delete the student with id id from the list if he's there and shifts the list maintaining its order.* getFirst(name: string): Student: this method should return the first Student in the list whose name is name if found getStudents(age: int):Student[]: this method should return an array of Students having age less than age if applicable printList: This method should display all the information of the students in the section. * These methods should print out useful messages on whether the operation was successful or not . Exercise 1: Translate into Java code classes Student and Section. Exercise 2: In a new class write a main method that tests the functionality of the previous classes: Create one section (e.g. CSC113, 12) Add five students to the section (e.g. 438102233, Faisal, 20), with two of them having the same name (e.g. Sultan) and with varying ages (19-22) Display the list Remove a student from the middle of the list Display the list one more time Get and print the first Sultan in the list Get and print the list of students younger than 21 etcStep 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