
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The solution to quiz 7 of the cmsc 131 fall 2004 course, focusing on the waitlist class. The waitlist class is implemented as a java public class with a constructor, add method, and tostring method. The constructor initializes an empty student array, the add method expands the array when needed and adds a new student object, and the tostring method returns a string representation of the array's student objects.
Typology: Quizzes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

public class WaitList { private Student[] array; /* constructor / public WaitList() { array = new Student[0]; } / add student – expand array if needed / public void add(Student student) { Student[] newArray = new Student[array.length+1]; for (int i = 0; i < array.length; i++) { newArray[i] = array[i]; } newArray[array.length] = new Student(student); array = newArray; } / toString */ public String toString() { String result = ""; for (int i = 0; i < array.length; i++) { result += array[i] + "\n"; } return result; } }