@@ -0,0 +1,2374 @@
+%0Aimport java.util.ArrayList;%0Apublic class Hotel%0A%7B%0A    /**%0A     * each element in rooms%5B%5D corresponds to a room in the hotel;%0A     * if rooms%5Bindex%5D is null, the room is empty;%0A     * otherwise, it contains a reference to the Reservation for%0A     * that room, such that%0A     * rooms%5Bindex%5D.getRoomNumber() returns index%0A     */%0A    private Reservation%5B%5D rooms;%0A%0A    /**%0A     * contains names of guests who have not yet been%0A     * assigned a room because all rooms are full%0A     */%0A    private ArrayList%3CString%3E waitList;%0A%0A    /**%0A     * Constructor - creates a Hotel with 'n' number of rooms%0A     */%0A    public Hotel(int nRooms)    %7B%0A        rooms = new Reservation%5BnRooms%5D;%0A        waitList = new ArrayList%3CString%3E();%0A    %7D%0A%0A    /**%0A     * if there are any empty rooms (rooms with no reservation),%0A     * then create a reservation for an empty room for the%0A     * specified guest and return the new Reservation;%0A     * otherwise, add the guest to the end of waitList%0A     * and return null%0A     */%0A    public Reservation requestRoom(String guestName)%0A    %7B%0A        for (int i=0; i%3Crooms.length; i++) %7B%0A            if (rooms%5Bi%5D == null) %7B%0A                rooms%5Bi%5D = new Reservation(guestName, i);%0A                return rooms%5Bi%5D;%0A            %7D%0A        %7D%0A        waitList.add(guestName);%0A        return null;%0A    %7D%0A%0A    /**%0A     * release the room associated with the room number of%0A     * parameter res, effectively canceling the reservation;%0A     *%0A     * if any names are stored in waitList, remove the first name%0A     * and create a Reservation for this person in the room%0A     * reserved by res; return that new Reservation;%0A     *%0A     * if waitList is empty, mark the room specified by res as empty%0A     * and return null%0A     *%0A     * precondition: res is a valid Reservation for some room%0A     *               in this hotel%0A     */%0A    public Reservation cancelAndReassign(Reservation res)%0A    %7B%0A        rooms%5Bres.getRoomNumber()%5D = null;%0A        if (waitList.size() %3E 0) %7B%0A            rooms%5Bres.getRoomNumber()%5D = new Reservation(waitList.get(0), res.getRoomNumber());%0A            waitList.remove(0);%0A        %7D%0A        return rooms%5Bres.getRoomNumber()%5D;%0A    %7D%0A%0A%0A    public String toString()    %7B%0A        String s = %22%22;%0A%0A        for (int i = 0; i %3C rooms.length; i++)%0A            s += rooms%5Bi%5D + %22 %22;%0A%0A        s += %22Waitlist: %22 + waitList;%0A        return s;%0A    %7D%0A%7D%0A

Create Hotel.java