Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to Object -Oriented Programming I - Quiz 7 | CMSC 131, Quizzes of Computer Science

Material Type: Quiz; Class: OBJECT-ORIENTED PROG I; Subject: Computer Science; University: University of Maryland; Term: Fall 2004;

Typology: Quizzes

Pre 2010

Uploaded on 07/30/2009

koofers-user-szg-1
koofers-user-szg-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

Related documents


Partial preview of the text

Download Introduction to Object -Oriented Programming I - Quiz 7 | CMSC 131 and more Quizzes Computer Science in PDF only on Docsity!

CMSC131 Fall 2004 Quiz #7, Duration 25 Minutes

First Name: Last Name: Student Id: Section time (10am/11am): TAs:

Problem Description

A class called WaitList represents a set of students waiting to get into a course. The class relies on a Student class defined as follows:

/* YOU MAY NOT MODIFY THIS CLASS */ public class Student { private String name; private int id;

public Student(String sname, int sid) { name = sname; id = sid; }

public Student(Student student) { name = new String(student.name); id = student.id; }

public int getId() { return id; }

public String toString() { return name + " " + id; } }

For this quiz you will implement the WaitList class. The class specifications are:

Instance Variable

Student[] array; // Array that represents the list of students

Methods

• Constructor – Creates a waitlist with no students.

• add – This method takes as parameter a reference to the student to be added. The method

makes a copy of the student object and adds the copy to the end of the array representing

the waitlist. The size of the array will be increased by one.

• toString – Returns a string with the name and id of every student in the waitlist.

Information about each student will appear on a line by itself.

WRITE YOUR IMPLEMENTATION ON THE NEXT PAGE

WRITE YOUR IMPLEMENTATION ON THIS PAGE