Package com.example.skeddly.business
Class TicketList
java.lang.Object
com.example.skeddly.business.TicketList
- Direct Known Subclasses:
ParticipantList,WaitingList
A list of tickets. This class is extended to make up the participant and final lists.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for unbounded ticket listTicketList(int max) Constructor for bounded ticket list -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a ticket to the waiting listintgetMax()Return the maximum number of people allowed in the ticket listReturn theArrayListof ticketsbooleanisEmpty()Gets whether the ticket list is empty or not.booleanisFull()Gets whether the ticket list is full or not.voidRemove a ticket from the ticket listvoidsetMax(int max) Set the maximum number of people allowed in the ticket listvoidsetTicketIds(ArrayList<String> ticketIds) Update theArrayListof ticketsintsize()Gets how many tickets are stored in the waiting list.
-
Constructor Details
-
TicketList
public TicketList(int max) Constructor for bounded ticket list- Parameters:
max- Maximum number of tickets
-
TicketList
public TicketList()Constructor for unbounded ticket list
-
-
Method Details
-
addTicket
Add a ticket to the waiting list- Parameters:
ticketId- Ticket to add- Throws:
IllegalArgumentException- If the list is already full
-
remove
Remove a ticket from the ticket list- Parameters:
ticketId- ID of the ticket to remove
-
getMax
public int getMax()Return the maximum number of people allowed in the ticket list- Returns:
- The maximum length of the list
-
setMax
public void setMax(int max) Set the maximum number of people allowed in the ticket list- Parameters:
max- The new limit
-
isFull
public boolean isFull()Gets whether the ticket list is full or not.- Returns:
- True if the ticket list is full. False otherwise.
-
isEmpty
public boolean isEmpty()Gets whether the ticket list is empty or not.- Returns:
- True if the waiting list is empty. False otherwise.
-
size
public int size()Gets how many tickets are stored in the waiting list.- Returns:
- The number of tickets in the waiting list.
-
getTicketIds
Return theArrayListof tickets- Returns:
- The ticketId list
-
setTicketIds
Update theArrayListof tickets- Parameters:
ticketIds- The new ticketId list
-