Question
Generic Class Exercise 2 In the lecture (unit1), we implement the concept of waiting list of generic type using an array. 1- Now, we want
Generic Class Exercise 2 In the lecture (unit1), we implement the concept of waiting list of generic type using an array.
1- Now, we want to implement the concept (as generic ) using ArrayList. Your generic WaitingList class should include the following method:
a- add: it receives generic type elements and add it to the end of the list.
b- get: it receives an index and returns the element at the specific index (if there is ), or null if there is no such index.
c- remove: it removes the first element, and returns that element.
d- print: it prints the elements in the waiting list. Create class GC_Test, that has main method. In the main,
a- Create WaitingList of Car, and add three cars.
b- Test method remove, reverse , and print the list after each method to test the methods.
c- Create WaitingList of Student, and add four students.
d- Test method remove, reverse , and print the list after each method to test the methods.
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