using System.Diagnostics;
public static void Main(string[] args)
Hotel hotel = new Hotel(5);
foreach(int room in new int[]{ 0,0,0,0,0,4,2,0,0})
public static void Test(Hotel hotel, int n)
Console.WriteLine("Room {0} allocated", hotel.checkIn());
Console.WriteLine("Room {0} freed", n);
public Hotel(int totalNumberOfRooms)
freeRooms = new Queue(totalNumberOfRooms);
for (int i = 1; i <= totalNumberOfRooms; i++)
public bool hasRoomsAvailable()
return !freeRooms.IsEmpty();
Trace.Assert(hasRoomsAvailable());
public void checkOut(int roomNumber)
freeRooms.Push(roomNumber);
return count == data.Length;
throw new ApplicationException("Queue full");
data[(head + count) % data.Length] = v;
throw new ApplicationException("Queue empty");
head = (head + 1) % data.Length;