import java.util.ArrayList;
public class Hotel {
/** Creates a new instance of Hotel */
public Hotel() {
}
private Reservation rooms[];
private ArrayList waitList;
public Reservation requestRoom(String name){
for(int i = 0; i < rooms.length; i++){
//if there is an empty room, make the reservation
if(rooms[i] == null){
Reservation res = new Reservation(name, rooms[i]);
return res;
}
Return null;
}
//add name to waitlist and return null if there are no rooms
waitList.add(name);
return null;
}
public Reservation cancelAndReassign(Reservation res){
int roomNumber = res.getRoomNumber();
for(int i = 0; i < rooms.length; i++){
if(rooms[i] == roomNumber){
if(!waitList.isEmpty()){
Reservation newRes = new
Reservation(waitList.remove(), rooms[i]);
return newRes;
}
else{
room[i] = null;
return null;
}
}
}
}