示例#1
0
        public void Add_hotel_test()
        {
            Hotel_management.Add_hotel("Royal", 50, 20);
            Hotel_management.Add_hotel("Ukraine", 20, 100);

            Assert.IsTrue(Hotel_management.hotels[1].Name == "Ukraine");
            Assert.IsTrue(Hotel_management.hotels[1].Rooms_amount == 20);
            Assert.IsTrue(Hotel_management.hotels[1].Price_per_day == 100);
        }
示例#2
0
        public void Order_request_test()
        {
            Hotel_management.Add_hotel("Royal", 50, 20);

            Hotel_management.Make_order_request("Royal", 10, 5, "7777777777");
            Hotel_management.Make_order_request("Royal", 15, 1, "4444444444");

            Assert.AreEqual(Hotel_management.hotels[0].order_requests[1].Phone_number_for_request, "4444444444");
            Assert.AreEqual(Hotel_management.hotels[0].order_requests[1].Room_number, 15);
            Assert.AreEqual(Hotel_management.hotels[0].order_requests[1].Days_amount, 1);
        }
示例#3
0
        public void Order_test()
        {
            Hotel_management.Clear_hotels_list();
            Client_management.Clear_clients_list();

            Hotel_management.Add_hotel("Ukraine", 50, 100);
            Hotel_management.Make_order_request("Ukraine", 5, 2, "5555555555");
            Client_management.Add_client("Gene", "Bloch", "MK754645", "5555555555");

            Room_ordering_management.Order_room(0, "Ukraine", "5555555555");

            Assert.IsTrue(Hotel_management.Find("Ukraine").approved_orders[0].Client.Passport == "MK754645");
        }
示例#4
0
        public void Remove_order_request_test()
        {
            Hotel_management.Clear_hotels_list();
            Hotel_management.Clear_order_requests_list();

            Hotel_management.Add_hotel("Royal", 50, 20);
            Hotel_management.Make_order_request("Royal", 10, 5, "7777777777");
            Hotel_management.Make_order_request("Royal", 15, 1, "4444444444");

            Hotel_management.Remove_order_request("Royal", 10);

            Assert.AreEqual(Hotel_management.Find("Royal").order_requests[0].Phone_number_for_request, "4444444444");
            Assert.AreEqual(Hotel_management.Find("Royal").order_requests[0].Room_number, 15);
            Assert.AreEqual(Hotel_management.Find("Royal").order_requests[0].Days_amount, 1);
        }
示例#5
0
        private static void Room_ordering_menu()
        {
            Console.Clear();
            Console.WriteLine("Room ordering management");
            Console.WriteLine("\t1 - Order room");
            Console.WriteLine("\t2 - Remove order");
            Console.WriteLine("\t3 - Order info");
            Console.WriteLine("\t4 - Show ordered rooms");
            Console.WriteLine("\t5 - Show free rooms");
            Console.WriteLine("\t6 - Show total price");
            Console.WriteLine("\t7 - Show clients");
            Console.WriteLine("\t0 - Turn back to main menu");

            try
            {
                int command = int.Parse(Console.ReadLine());

                switch (command)
                {
                case 0:
                    Main_menu();
                    break;

                case 1:
                    Console.Clear();
                    Client_management.Info_about_all_clients();

                    Console.Write("Hotel name: ");
                    string hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Client id: ");
                    int id = int.Parse(Console.ReadLine());

                    Console.Write("Phone number: ");
                    string phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex);

                    Console.Clear();

                    if (hotel_name != "" && phone_number != "")
                    {
                        Room_ordering_management.Order_room(id, hotel_name, phone_number);
                        Console.WriteLine("Successfully ordered");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                case 2:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Client id: ");
                    id = int.Parse(Console.ReadLine());

                    Console.Write("Room number: ");
                    int room_number = int.Parse(Console.ReadLine());

                    Console.Clear();

                    if (hotel_name != "")
                    {
                        Room_ordering_management.Remove_order(id, hotel_name, room_number);
                        Console.WriteLine("Successfully removed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                case 3:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Order id: ");
                    int order_id = int.Parse(Console.ReadLine());

                    Console.Clear();

                    if (hotel_name != "")
                    {
                        Room_ordering_management.Order_info(hotel_name, order_id);
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                case 4:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Clear();

                    if (hotel_name != "")
                    {
                        if (Hotel_management.Find(hotel_name).approved_orders.Count == 0)
                        {
                            Console.WriteLine("There are no orders in the hotel");
                        }
                        else
                        {
                            Room_ordering_management.Show_ordered_rooms(hotel_name);
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                case 5:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Clear();

                    if (hotel_name != "")
                    {
                        Room_ordering_management.Show_free_rooms(hotel_name);
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                case 6:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Order id: ");
                    order_id = int.Parse(Console.ReadLine());

                    Console.Clear();

                    if (hotel_name != "")
                    {
                        Room_ordering_management.Show_price(hotel_name, order_id);
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                case 7:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    hotel_name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Clear();

                    if (hotel_name != "")
                    {
                        if (Hotel_management.Find(hotel_name).approved_orders.Count == 0)
                        {
                            Console.WriteLine("There are no clients");
                        }
                        else
                        {
                            Room_ordering_management.Show_clients(hotel_name);
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Room_ordering_menu();
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("Invalid input");
                    Console.ReadKey();
                    break;
                }
            }
            catch
            {
                Console.WriteLine("ERROR");
                Console.ReadKey();
            }
        }
示例#6
0
        private static void Hotel_management_menu()
        {
            Console.Clear();
            Console.WriteLine("Hotel management");
            Console.WriteLine("\t1 - Add hotel");
            Console.WriteLine("\t2 - Remove hotel");
            Console.WriteLine("\t3 - Show info about a hotel");
            Console.WriteLine("\t4 - Show info about all hotels");
            Console.WriteLine("\t5 - Make order request");
            Console.WriteLine("\t6 - Remove order request");
            Console.WriteLine("\t7 - Change order request");
            Console.WriteLine("\t8 - Show order requests");
            Console.WriteLine("\t9 - Search by name");
            Console.WriteLine("\t10 - Search by price");
            Console.WriteLine("\t0 - Turn back to main menu");

            try
            {
                int command = int.Parse(Console.ReadLine());

                switch (command)
                {
                case 0:
                    Main_menu();
                    break;

                case 1:
                    Console.Clear();

                    Console.Write("Hotel name: ");
                    string name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Rooms amount: ");
                    int rooms_amount = int.Parse(Console.ReadLine());

                    Console.Write("Price per day: ");
                    int price_per_day = int.Parse(Console.ReadLine());

                    if (name != "" && Hotel_management.Is_unique_name(name))
                    {
                        Hotel_management.Add_hotel(name, rooms_amount, price_per_day);
                        Console.WriteLine("Successfully added");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 2:
                    Console.Clear();

                    Console.Write("Hotel name: ");
                    string hotel_to_remove = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    if (hotel_to_remove != "")
                    {
                        Hotel_management.Remove_hotel(hotel_to_remove);
                        Console.WriteLine("Successfully removed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 3:
                    Console.Clear();

                    Console.Write("Hotel name: ");
                    name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Clear();

                    if (name != "")
                    {
                        Hotel_management.Hotel_info(name);
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 4:
                    Console.Clear();

                    if (Hotel_management.hotels.Count == 0)
                    {
                        Console.WriteLine("Hotels list is empty");
                    }
                    else
                    {
                        Hotel_management.Info_about_all_hotels();
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 5:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Room number: ");
                    int room_number = int.Parse(Console.ReadLine());

                    Console.Write("Days amount: ");
                    int days_amount = int.Parse(Console.ReadLine());

                    Console.Write("Client phone number: ");
                    string client_phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex);

                    if (name != "" && client_phone_number != "")
                    {
                        Hotel_management.Make_order_request(name, room_number, days_amount, client_phone_number);
                        Console.WriteLine("Order request was successfully sent");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 6:
                    Console.Clear();

                    Console.Write("Hotel name: ");
                    name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Room number: ");
                    room_number = int.Parse(Console.ReadLine());

                    if (name != "")
                    {
                        Hotel_management.Remove_order_request(name, room_number);
                        Console.WriteLine("Order request was successfully removed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 7:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Write("Old room number: ");
                    int old_room_number = int.Parse(Console.ReadLine());

                    Console.Write("New room number: ");
                    int new_room_number = int.Parse(Console.ReadLine());

                    Console.Write("Days amount: ");
                    days_amount = int.Parse(Console.ReadLine());

                    Console.Write("Client phone number: ");
                    client_phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex);

                    if (name != "" && client_phone_number != "")
                    {
                        Hotel_management.Change_order_request(name, old_room_number, new_room_number, days_amount, client_phone_number);
                        Console.WriteLine("Order request was successfully changed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 8:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Clear();

                    if (name != "")
                    {
                        if (Hotel_management.Find(name).order_requests.Count == 0)
                        {
                            Console.WriteLine("There are no order requests for the hotel");
                        }
                        else
                        {
                            Hotel_management.Show_order_requests(name);
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 9:
                    Console.Clear();
                    Console.Write("Hotel name: ");
                    name = Check.Check_value(Console.ReadLine(), hotel_name_regex);

                    Console.Clear();

                    if (name != "")
                    {
                        Hotel_management.Hotel_info(Hotel_management.Search(name));
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                case 10:
                    Console.Clear();
                    Console.Write("Price per day: ");
                    price_per_day = int.Parse(Console.ReadLine());

                    Console.Clear();

                    int i = 0;
                    while (i < Hotel_management.Search(price_per_day).Count)
                    {
                        Hotel h = Hotel_management.Search(price_per_day)[i];
                        Hotel_management.Hotel_info(h);

                        if (i != Hotel_management.Search(price_per_day).Count - 1)
                        {
                            Console.WriteLine("- - - - - - - - - -");
                        }

                        i++;
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Hotel_management_menu();
                    break;

                default:
                    Console.WriteLine("Invalid input");
                    Console.ReadKey();
                    break;
                }
            }
            catch
            {
                Console.WriteLine("ERROR");
                Console.ReadKey();
            }
        }