Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 1: Array of Objects Student id : int name : String age: int Student) Student(int, String, int) H setId(int) : void setName(String) : void

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Lab 1: Array of Objects Student id : int name : String age: int Student) Student(int, String, int) H 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[ 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 . seld(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, sice: 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 Student(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. 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 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 (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 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. Falsal 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago