?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Class Design and Instance Variables

APCSA-NNAG1G

You are asked to define a Restaurant class to store information about a restaurant. A requirement is that you store all the reservations for the upcoming week in this class. Reservations will be deleted and added throughout the week. A Reservation is composed of the date/time of the reservation, the customer’s name, and their telephone number.

Of the following options, what would be the best choice for designing the Restaurant class to deal with reservations?

A

Create a Restaurant class, and within it create 3 instance variables representing: date/time of reservation, customer name, and telephone number.

B

Create a Restaurant class with 3 separate instance variables representing: an array of date/time of reservations, an array of customer names, and an array of telephone numbers.

C

Create a Reservation class with 3 instance variables representing: date/time of reservation, customer name, and telephone number. In the Restaurant class, create an instance variable representing an array of Reservation objects.

D

Create a Reservation class with 3 instance variables representing: date/time of reservation, customer name, and telephone number. In the Restaurant class, create an instance variable representing a Reservation object.

E

Create a Reservation class with 3 instance variables representing: date/time of reservation, customer name, and telephone number. In the Restaurant class, create an instance variable representing an ArrayList of Reservation objects.