import java.util.*; /** * This is my own Free Response question do not be intimidated * the first question is of harder difficulty than the second one. * * @author Carlos Vega, adaptations by FC * @version 004/30/22 */ public class Restaurant { private ArrayList waitingList; public Restaurant() { waitingList = new ArrayList(); } /** @returns the index, where reservation is located. * If it cannot find the reservation, it will return -1. * @param the name of the customer and their party size. * Precondition: name is in lower case * or one more reservation. */ public int findReservation(String name, int seats) { /* to be implemented in part (a) */ } /** checkIn will update the waitingList * If the reservation is found, it will be removed from waitingList. * If it is not found, a new Reservation will be added to waitingList. * Make sure not to duplicate code. You made presume that the method * written in part(a) works perfectly. * @param the name of the customer being located the party size. * Precondition: name is in lower case, seats >=0 * Postcondition: tables with either have one less reservation, * or one more reservation * @return true if the reservation was found, and customer is checked in * false if the reservation as not found, and the customer has been added to * waitingList */ public boolean checkIn (String name, int seats) { /* to be implemented in part (b) */ } // not shown in question public void add(Reservation r) { waitingList.add(r); } public int getLength() { return waitingList.size(); } public String toString() { String list= "Reservation list: \n"; for (int i=0; i < waitingList.size(); i++) { list += waitingList.get(i) + "\n"; } return list; } }