static void Main(string[] args) { Console.WriteLine("Please enter number of rooms:"); int numberOfRooms = ReadIntegerInputData(); IReservationsManager manager = ReservationsManagerProvider.GetManager(numberOfRooms); string response; do { Console.WriteLine("Please enter the start date of your reservation:"); int start = ReadIntegerInputData(); Console.WriteLine("Please enter the end date of your reservation:"); int end = ReadIntegerInputData(); if (manager.TryReserveRoom(start, end)) { Console.WriteLine("Reservation is accepted."); } else { Console.WriteLine("Reservation is not accepted."); } Console.WriteLine("Do you want to make another reservation? (y/n)"); response = Console.ReadLine().Trim().ToLower(); }while (response == "y" || response == "yes"); }
public void RequestsOutsidePlanningPeriodDeclined() { IReservationsManager manager = ReservationsManagerProvider.GetManager(1); Assert.IsFalse(manager.TryReserveRoom(-4, 2)); Assert.IsFalse(manager.TryReserveRoom(200, 400)); Assert.IsFalse(manager.TryReserveRoom(5, 3)); }
public void OneRequestDeclined() { IReservationsManager manager = ReservationsManagerProvider.GetManager(3); Assert.IsTrue(manager.TryReserveRoom(1, 3)); Assert.IsTrue(manager.TryReserveRoom(2, 5)); Assert.IsTrue(manager.TryReserveRoom(1, 9)); Assert.IsFalse(manager.TryReserveRoom(0, 15)); }
public void AllRequestsAccepted() { IReservationsManager manager = ReservationsManagerProvider.GetManager(3); Assert.IsTrue(manager.TryReserveRoom(0, 5)); Assert.IsTrue(manager.TryReserveRoom(7, 13)); Assert.IsTrue(manager.TryReserveRoom(3, 9)); Assert.IsTrue(manager.TryReserveRoom(5, 7)); Assert.IsTrue(manager.TryReserveRoom(6, 6)); Assert.IsTrue(manager.TryReserveRoom(0, 4)); }
public void ComplexRequests() { IReservationsManager manager = ReservationsManagerProvider.GetManager(2); Assert.IsTrue(manager.TryReserveRoom(0, 4)); Assert.IsTrue(manager.TryReserveRoom(1, 3)); Assert.IsFalse(manager.TryReserveRoom(2, 3)); Assert.IsTrue(manager.TryReserveRoom(5, 5)); Assert.IsTrue(manager.TryReserveRoom(4, 10)); Assert.IsTrue(manager.TryReserveRoom(10, 10)); Assert.IsTrue(manager.TryReserveRoom(6, 7)); Assert.IsFalse(manager.TryReserveRoom(8, 10)); Assert.IsTrue(manager.TryReserveRoom(8, 9)); }