Question: Lab 1: Array of Objects Student - id : int name : String age : int Student Student(int, String, int) + setld(int) : void setName(String):


![getAge(int display : void Section course String studentList: Student[] - nStudents int](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3069f901de_97566f3069f2dd9c.jpg)
Lab 1: Array of Objects Student - id : int name : String age : int Student Student(int, String, int) + setld(int) : void setName(String): void + setAge(int) : void getld) :int getName(): String + getAge(int display : void Section course String studentList: Student[] - nStudents int Section(String, int) search Student(int) : int + addStudent(int, String, int) : void + delete Students(int) : void getFirst(String): Student + getStudents(int) Student[] printListo): 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 set/d(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 Students, the number of students in the section Methods: Section course string, size: int constructor search Studentid:int): this method should search the list for a student using his id and return the index if he's there or otherwise . . . . . . add Studentid: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. delete Studentid: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 retum the first Student in the list whose name is name if found gerStudents(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 (eg CSC113, 12) Add five students to the section (eg. 438102233, Faisal, 20), with two of them having the same name (eg 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 R. Get and print the first Sultan in the list Get and print the list of students younger than 21 . . etc 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. All, 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, All, 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 delete Student on id 441105008, and then call printList: +441107008. Sultan, 19 +441106008, Mohammed. 19 +441 104008, Mohammed, 21 Good luck
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
