Class GuestList
java.lang.Object
it.unimi.di.prog2.h12.GuestList
Guest list for a private party of prescribed capacity.
Guests are identified by their names that are represented by strings, which must not be null or empty; no check on duplicates is performed.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
guests
-
capacity
private final int capacityThe maximum capacity of the guest list.
-
-
Constructor Details
-
GuestList
public GuestList(int capacity) Builds an empty guest list with the given maximum capacity.- Parameters:
capacity- the maximum size of the guest list.- Throws:
IllegalArgumentException- ifcapacityis not positive.
-
GuestList
Builds a guest list with the given maximum capacity, populated with an initial list of guests.- Parameters:
guests- the initial list of guests.capacity- the maximum size of the guest list.- Throws:
IllegalArgumentException- ifcapacityis not positive.IllegalArgumentException- ifguests.size()is greater thancapacity.NullPointerException- ifguestsis null or containsnull.
-
-
Method Details
-
guests
-
invite
Adds a guest to this guest list.- Parameters:
guest- the guest name.- Throws:
IllegalStateException- if the list has reached its maximum capacity.NullPointerException- ifguestisnull.
-
toString
-