Example #1
0
        private static void RunTestCases()
        {
            Hotel hotel;

            // Test Case I
            Console.WriteLine("Test Case 1a/1b, outside planning periods");
            hotel = new Hotel(1);
            hotel.MakeReservation(-4, 2);
            Console.WriteLine("\nTest Case 2, size = 3");
            hotel = new Hotel(3);
            hotel.MakeReservation(0, 5);
            hotel.MakeReservation(7, 13);
            hotel.MakeReservation(3, 9);
            hotel.MakeReservation(5, 7);
            hotel.MakeReservation(6, 6);
            hotel.MakeReservation(0, 4);
            Console.WriteLine("\nTest Case 3, size = 3");
            hotel = new Hotel(3);
            hotel.MakeReservation(1, 3);
            hotel.MakeReservation(2, 5);
            hotel.MakeReservation(1, 9);
            hotel.MakeReservation(0, 15);
            Console.WriteLine("\nTest Case 4, size = 3");
            hotel = new Hotel(3);
            hotel.MakeReservation(1, 3);
            hotel.MakeReservation(0, 15);
            hotel.MakeReservation(1, 9);
            hotel.MakeReservation(2, 5);
            hotel.MakeReservation(4, 9);
            Console.WriteLine("\nTest Case 5, size = 2");
            hotel = new Hotel(2);
            hotel.MakeReservation(1, 3);
            hotel.MakeReservation(0, 4);
            hotel.MakeReservation(2, 3);
            hotel.MakeReservation(5, 5);
            hotel.MakeReservation(4, 10);
            hotel.MakeReservation(10, 10);
            hotel.MakeReservation(6, 7);
            hotel.MakeReservation(8, 10);
            hotel.MakeReservation(8, 9);
            Console.WriteLine("\n End of test cases...");
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press ENTER to make a custom reservation \nor\nType in 't' to run test cases");
            string input = Console.ReadLine();

            if (input.Equals("t") || input.Equals("T"))
            {
                RunTestCases();
                return;
            }


            int size;

            Console.WriteLine("Hotel size: ");

            if (!int.TryParse(Console.ReadLine(), out size) || size < 0)
            {
                Console.WriteLine("Positive number expected");
                return;
            }

            Hotel hotel        = new Hotel(size);
            bool  appIsRunning = true;
            int   start;
            int   end;

            while (appIsRunning)
            {
                try
                {
                    Console.Write("Start date: ");
                    start = int.Parse(Console.ReadLine());
                    Console.Write("End date: ");
                    end = int.Parse(Console.ReadLine());
                }
                catch (FormatException)
                {
                    Console.WriteLine("Positive numbers expected");
                    break;
                    // throw;
                }

                // Method will check for available rooms and output
                // wether the reservation was accepted or declined
                hotel.MakeReservation(start, end);

                Console.WriteLine("Press ENTER to make another reservation, type in 'stop' to exit app");
                if (Console.ReadLine().Equals("stop"))
                {
                    appIsRunning = false;
                }
            }
        }