Beispiel #1
0
        public static void ToBookARoom(Hotel hotel, Guest guest)
        {
            int[]  rooms    = null;
            string category = "";

            Console.WriteLine("What type of room would you like to book?");
            Console.WriteLine("1 Standart");
            Console.WriteLine("2 Medium");
            Console.WriteLine("3 Lux");
            category = Console.ReadLine();
            switch (category)
            {
            case null:
                Console.WriteLine("Sorry you did something wrong.");
                break;

            case "1":
                rooms = Hotel.Standart;
                break;

            case "2":
                rooms = Hotel.Medium;
                break;

            case "3":
                rooms = Hotel.Lux;
                break;

            default:
                throw new Exception();
            }
            Console.WriteLine("How many days are you planning to stay?");
            int day = Convert.ToInt32(Console.ReadLine());

            if (day <= 0)
            {
                throw new Exception();
            }
            decimal topay = day * hotel[rooms[0]].Price;

            Console.WriteLine($"To pay: {topay}.");
            Console.ReadKey();
            Console.WriteLine("*money*");
            Console.ReadKey();
            foreach (int r in rooms)
            {
                if (guest.ToBook(day, hotel[r]))
                {
                    Hotel.Booked.Add(r, guest);
                    break;
                }
            }
        }