예제 #1
0
        public void GetObject()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms = rooms;

            Assert.IsNotNull(hotel.GetObject(new Point(10, 10)));
        }
예제 #2
0
        public void EventHandlerConstructor()
        {
            Hotel.Hotel       hotel   = new Hotel.Hotel();
            HotelEventHandler handler = new HotelEventHandler(hotel);

            Assert.IsNotNull(handler);
        }
예제 #3
0
        public void AddGuestsTest()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms = rooms;
            hotel.AddGuest("John", 1);

            Assert.IsTrue(hotel.Guests.Count == 1);
        }
예제 #4
0
        public void RemoveObjTestGuest()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms = rooms;
            hotel.AddGuest("John", 1);
            hotel.Guests["John"].Remove();

            Assert.IsTrue(hotel.Guests.Count == 0);
        }
예제 #5
0
        public void RemoveObjTestReceptionist()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms = rooms;
            hotel.CreateStaff();
            hotel.Staff[0].Remove();

            Assert.IsTrue(hotel.Staff.Count == 0);
        }
예제 #6
0
        public void AddStaffTest()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms = rooms;
            hotel.CreateStaff();

            // Created a receptionist.
            Assert.IsTrue(hotel.Staff.Count == 1);
        }
예제 #7
0
        public void SendCleanerToDirtyRoom()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms           = rooms;
            hotel.Rooms[12].State = RoomState.Dirty;
            Cleaner cl = new Cleaner(hotel.Rooms[12]);

            hotel.Staff.Add(cl);
            hotel.Update(1);
            Assert.IsTrue(hotel.Rooms[12].State == RoomState.InCleaning);
        }
예제 #8
0
        public void Evacuation()
        {
            Hotel.Hotel hotel = new Hotel.Hotel();
            hotel.Rooms = rooms;
            Cleaner cl    = new Cleaner(hotel.Rooms[0]);
            Guest   guest = new Guest(hotel.Rooms[0]);

            guest.Room = (GuestRoom)hotel.Rooms[15];
            hotel.Guests.Add("guest1", guest);
            hotel.Staff.Add(cl);

            hotel.Evacuating = true;

            hotel.Update(1);

            Assert.IsFalse(hotel.Evacuating);
        }
예제 #9
0
        public void CleanerGhostArrivalOutside()
        {
            Hotel.Hotel hotel   = new Hotel.Hotel();
            GuestRoom   room    = new GuestRoom(1, new Point(1, 0), new Point(1, 1), 1);
            EmptyRoom   outside = new EmptyRoom(0, new Point(0, 0), new Point(1, 1));

            outside.Entrance = true;
            hotel.Rooms.Add(room);
            hotel.Rooms.Add(outside);

            room.Neighbors.Add(Direction.West, room);
            outside.Neighbors.Add(Direction.East, room);

            CleanerGhost ghost = new CleanerGhost(outside);

            ghost.RemoveObjectEvent += hotel.RemoveObject;
            hotel.Staff.Add(ghost);

            hotel.Update(1);
            ghost.OnArrival();
            hotel.Update(1);

            Assert.IsTrue(hotel.Staff[0] is Cleaner);
        }
예제 #10
0
        static void Main(string[] args)
        {
            try
            {
                Hotel hotel = new Hotel(Hotel.Rooms);

                string choice = "";

                Console.WriteLine("Please, enter guest's name: ");
                string name = Console.ReadLine();
                if (name == null)
                {
                    throw new Exception("The name input is not correct.");
                }
                Console.WriteLine("Please, enter guest's age");
                int age = Convert.ToInt32(Console.ReadLine());
                if (name == null)
                {
                    throw new Exception("The age input is not correct.");
                }
                Guest guest = new Guest(name, age);


                while (true)
                {
                    Console.WriteLine("Please, choose a number according to your purpose:");
                    Console.WriteLine("1. To book a room.");
                    Console.WriteLine("2. To rent a room now.");
                    Console.WriteLine("3. To display the information about hotel room.");
                    Console.WriteLine("4. To display guest's card");
                    Console.WriteLine("0. Exit");



                    choice = Console.ReadLine();

                    switch (choice)
                    {
                    case "1":
                        ToBookARoom(hotel, guest);
                        break;

                    case "2":
                        ToRentARoom(hotel, guest);
                        break;

                    case "3":
                        RoomInfo(hotel);
                        break;

                    case "4":
                        GetCard();
                        break;

                    case "0":
                        return;

                    default:
                        throw new Exception();
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Error");
            }
        }
예제 #11
0
 public void HotelConstructor()
 {
     Hotel.Hotel hotel = new Hotel.Hotel();
     Assert.IsNotNull(hotel);
 }
        static void Main()
        {
            #region Lab1-2-3-4-5

            #region Lab1-2-3

            Console.WriteLine("\n--------Lab1-2-3--------");

            Hotel RedHotel = new Hotel(1, "Адам", "вул. Т. Шевченка",
                                       "Дуже крутий опис дуже крутого готелю, який всім дуже " +
                                       "подобається")
            {
                City          = City.Kyiv,
                Rating        = 32,
                NumberOfStars = 3
            };

            User AdminV = new User(1, 2, "AdminValera", "*****@*****.**",
                                   "+069069696");

            RedHotel.CreateRoom(2, 2, "Red", 1, RedHotel, true, "Big", 5, true);

            RedHotel.CreateOrder(1, 300, RedHotel, AdminV, "1", RedHotel.Rooms[0],
                                 DateTime.Now, DateTime.Now.AddDays(7));

            ConcreteOrder order = new ConcreteOrder(2, 300, RedHotel, AdminV,
                                                    "2", RedHotel.Rooms[1],
                                                    DateTime.Now, DateTime.Now.AddDays(7))
            {
                DateStart = DateTime.Parse("22.01.2002")
            };

            // Constructor by default
            User GreatValeera = new User
            {
                UserName = "******"
            };

            // Copy Constructor
            User GreaterValeera = new User(GreatValeera);

            #endregion Lab1-2-3

            #region Lab4

            Console.WriteLine("\n--------Lab4--------");

            #region Unary

            Console.WriteLine("\n--Перевантаження унарних операторiв:--\n");

            Console.WriteLine($"Кiлькiсть зiрок: {RedHotel.NumberOfStars}");
            ++RedHotel;
            Console.WriteLine($"Кiлькiсть зiрок пiсля збiльшення:" +
                              $" {RedHotel.NumberOfStars}");
            --RedHotel;
            Console.WriteLine($"Кiлькiсть зiрок пiсля зменшення:" +
                              $" {RedHotel.NumberOfStars}");

            Console.WriteLine();

            Console.WriteLine($"Кiлькiсть лiжок: {RedHotel.Rooms[0].NumberOfBeds}");
            ++RedHotel.Rooms[0];
            Console.WriteLine($"Кiлькiсть зiрок пiсля збiльшення:" +
                              $" {RedHotel.Rooms[0].NumberOfBeds}");
            --RedHotel.Rooms[0];
            Console.WriteLine($"Кiлькiсть зiрок пiсля зменшення:" +
                              $" {RedHotel.Rooms[0].NumberOfBeds}");

            #endregion Unary

            #region Binary

            Console.WriteLine("\n--Перевантаження бiнарних операторiв:--\n");

            Console.WriteLine("Iм'я першої кiмнати = "
                              + RedHotel.Rooms[0].RoomName);
            Console.WriteLine("Iм'я другої кiмнати = "
                              + RedHotel.Rooms[1].RoomName);

            Console.WriteLine($"Розмiр першої кiмнати = " +
                              $"{RedHotel.Rooms[0].RoomSize}\nРозмiр другої " +
                              $"кiмнати = {RedHotel.Rooms[1].RoomSize}\n");

            Room newRoom = RedHotel.Rooms[0] + RedHotel.Rooms[1];

            Console.WriteLine("Iм'я нової першої кiмнати = "
                              + RedHotel.Rooms[0].RoomName);

            Console.WriteLine($"Розмiр нової, об'єднаної кiмнати = " +
                              $"{newRoom.RoomSize}");

            #endregion Binary

            #region Logical

            Console.WriteLine("\n--Перевантаження логiчних операторiв:--\n");

            if (RedHotel)
            {
                Console.WriteLine("Рейтинг додатнiй");
            }
            RedHotel.Rating = 23;
            if (!RedHotel)
            {
                Console.WriteLine("Рейтинг вiд'ємний");
            }

            Console.WriteLine();

            if (order)
            {
                Console.WriteLine("Замовлення ще активне");
            }
            order.DateEnd = DateTime.Parse("22.01.2002");
            if (!order)
            {
                Console.WriteLine("Замовлення вже не активне");
            }

            Console.WriteLine();

            if (AdminV)
            {
                Console.WriteLine("Користувач має пошту та телефон");
            }
            GreatValeera.UserMail    = "*****@*****.**";
            GreaterValeera.UserMail  = "*****@*****.**";
            GreatValeera.UserPhone   = "+069069696";
            GreaterValeera.UserPhone = "+069069696";
            if (GreatValeera & GreaterValeera)
            {
                Console.WriteLine("Користувачi мають пошту та телефон");
            }

            #endregion Logical

            #region Comparison

            Console.WriteLine("\n--Перевантаження операторiв порiвняння:--\n");

            Hotel BlueHotel = new Hotel(2, "Єва", "вул. Т. Шевченка",
                                        "Не дуже крутий опис не дуже крутого готелю, який не всiм не дуже " +
                                        "не подобається")
            {
                City          = City.Kyiv,
                Rating        = 32,
                NumberOfStars = 3
            };

            BlueHotel.CreateRoom(2, 2, "Blue", 5, BlueHotel, false, "Big", 15, true);

            Console.WriteLine($"Кiлькiсть зiрок, рейтинг Готелю " +
                              $"1: {RedHotel.NumberOfStars}, {RedHotel.Rating}");
            Console.WriteLine($"Кiлькiсть зiрок, рейтинг Готелю " +
                              $"2: {BlueHotel.NumberOfStars}, {BlueHotel.Rating}");

            Console.WriteLine($"Перевiряємо рiвнозначнiсть Готелю 1 " +
                              $"та Готелю 2: {RedHotel == BlueHotel}");
            Console.WriteLine($"Перевiряємо нерiвнозначнiсть Готелю 1 " +
                              $"та Готелю 2: {RedHotel != BlueHotel}");
            Console.WriteLine();

            Console.WriteLine($"Кiлькiсть лiжок, розмiр, наявнiсть" +
                              $" телевiзора та балкону в Кiмнатi 1: " +
                              $"{RedHotel.Rooms[0].NumberOfBeds}, " +
                              $"{RedHotel.Rooms[0].RoomSize}, {RedHotel.Rooms[0].TV}," +
                              $" {RedHotel.Rooms[0].Balcony}");
            Console.WriteLine($"Кiлькiсть лiжок, розмiр, наявнiсть" +
                              $" телевiзора та балкону в Кiмнатi 2: " +
                              $"{BlueHotel.Rooms[0].NumberOfBeds}, " +
                              $"{BlueHotel.Rooms[0].RoomSize}, {BlueHotel.Rooms[0].TV}, " +
                              $"{BlueHotel.Rooms[0].Balcony}");

            Console.WriteLine($"Перевiряємо рiвнозначнiсть Кiмнати 1 та " +
                              $"Кiмнати 2: {RedHotel.Rooms[0] == BlueHotel.Rooms[0]}");
            Console.WriteLine($"Перевiряємо нерiвнозначнiсть Кiмнати 1 та " +
                              $"Кiмнати 2: {RedHotel.Rooms[0] != BlueHotel.Rooms[0]}");

            #endregion Comparison

            #endregion Lab4

            #region Lab5

            Console.WriteLine("\n--------Lab5--------");

            #region Base-Classes-And-Inheritence

            Console.WriteLine("\n--Базовi та похiднi класи:--");

            Console.WriteLine("\nСтворюємо вiдвiдувача:");
            Customer Customer = new Customer(7,
                                             "*****@*****.**", "Genji", "+067069696");

            Console.WriteLine("\nСтворюємо адмiна:");
            Admin Admin = new Admin(8, "*****@*****.**",
                                    "Hanzo", "+069069698");

            #endregion Base-Classes-And-Inheritence

            #region Abstract-Classes-And-Virtual-Methods

            Console.WriteLine("\n--Абстрактнi класи та вiртуальнi методи:--");

            Console.WriteLine("\nВикористовуємо перший override конструктор:");

            NotSoConcreteOrder NotSoConcreteOrder = new NotSoConcreteOrder(50,
                                                                           666, BlueHotel, Admin, "3", BlueHotel.Rooms[0],
                                                                           DateTime.Now, DateTime.Now.AddDays(7));

            Console.WriteLine("\nВикористовуємо другий override конструктор:");

            ConcreteOrder ConcreteOrder = new ConcreteOrder(51,
                                                            667, BlueHotel, Customer, "4", BlueHotel.Rooms[1],
                                                            DateTime.Now, DateTime.Now.AddDays(7));

            Console.WriteLine("\nВикористовуємо перший override метод:");

            NotSoConcreteOrder.IsExpired();

            Console.WriteLine("\nВикористовуємо перший не override метод:");

            ConcreteOrder.IsExpired();

            Console.WriteLine("\nВикористовуємо другий override метод:");

            NotSoConcreteOrder.BelongsTo();

            Console.WriteLine("\nВикористовуємо другий не override метод:");

            ConcreteOrder.BelongsTo();

            #endregion Abstract-Classes-And-Virtual-Methods

            #region Interface

            Console.WriteLine("\n--Iнтерфейси:--");

            Console.WriteLine("\nСтворюємо готель через iнтерфейс:");

            IRoom greenHotel = new Hotel(4, "GreenDeer", "вул. Т. Шевченка",
                                         "Myyyyyyyyyyyyyyyyy Myyyyyyyyyyyyyyyyy " +
                                         "Myyyyyyyyyyyyyyyyy Myyyyyyyyyyyyyyyyy Myyyyyyyyyyyyyyyyy")
            {
                City          = City.Kyiv,
                Rating        = 12,
                NumberOfStars = 5
            };

            greenHotel.CreateRoom(2, 2, "aZUL", 1, (Hotel)greenHotel
                                  /*Downcasting*/, true, "Big", 5, true);

            #endregion Interface

            #region Upcast, Downcast

            Console.WriteLine("\n--Upcast та Downcast:--");

            // Upcast
            Customer customer = new Customer(7,
                                             "*****@*****.**", "Genji", "+067069696");
            Admin admin = new Admin(8,
                                    "*****@*****.**", "Hanzo", "+069069698");

            User customerUser = customer;
            User adminUser    = admin;

            Console.WriteLine("\n--Показуємо типи об'єктiв" +
                              " пiсля Upcast:--");

            Console.WriteLine(customerUser.GetType());
            Console.WriteLine(adminUser.GetType());
            Customer customer1 = (Customer)customerUser;
            Admin    admin1    = (Admin)adminUser;

            Console.WriteLine("\n--Показуємо властивостi " +
                              "об'єктiв пiсля Downcast:--");

            Console.WriteLine(customer1.UserTypeName);
            Console.WriteLine(admin1.UserTypeName);

            #endregion Upcast, Downcast

            #endregion Lab5

            #endregion Lab1-2-3-4-5

            #region Lab6

            Console.WriteLine("\n--------Lab6--------");

            #region Events

            Console.WriteLine("\n--Подiї:--\n");

            Hotel EventHotel = new Hotel(56, "Подiя", "вул. Т. Шевченка",
                                         "Дуже крутий опис дуже крутого готелю, який всім дуже " +
                                         "подобається")
            {
                City          = City.Kyiv,
                Rating        = 35,
                NumberOfStars = 4
            };

            EventHotel.EventForNotifying += DisplayMessage;

            EventHotel.CreateRoom(2, 2, "Подiя", 1, EventHotel, true, "Big", 5, true);

            #endregion Events

            #region Anonymous-Methods

            Console.WriteLine("\n--Анонiмнi методи:--\n");

            Room.ShowSomeString("1. Анонiмний метод класу Room.", delegate(string messageString)
            {
                Console.WriteLine(messageString);
            });

            Hotel.ShowSomeString("2. Анонiмний метод класу Hotel.", delegate(string messageString)
            {
                Console.WriteLine(messageString);
            });

            #endregion Anonymous-Methods

            #region Lambda

            Console.WriteLine("\n--Лямбди:--\n");

            Console.WriteLine("Коефiцiєнт просторностi кiмнати: "
                              + RedHotel.Rooms[0].SpaceKoeff);

            RedHotel.Rooms[0].CheckHotelPrice(x => DateTime.Now.DayOfWeek
                                              != DayOfWeek.Sunday);

            decimal priceOne()
            {
                return(order.Room.NumberOfBeds == 0 ? 1
                                        : order.Sum / order.Room.NumberOfBeds);
            }

            Console.WriteLine("Цiна за одну людину в кiмнатi: " + priceOne());

            #endregion Lambda

            #endregion Lab6

            Console.WriteLine("\n--------Credits-------");

            Console.WriteLine("\nFirst Team: Zavalniuk Maxim," +
                              "\nDmytrenko Roman,\n" +
                              "Sichkar Tetiana,\nDominskyi Valentyn");

            Console.ReadLine();
        }
예제 #13
0
        public static void ToRentARoom(Hotel hotel, Guest guest)
        {
            int[] rooms = null;
            foreach (KeyValuePair <int, Guest> Pair in Hotel.Booked)
            {
                if (Pair.Value.Name == guest.Name)
                {
                    DateTime time = DateTime.Now;
                    Console.WriteLine($"You have rented a room #{Pair.Key + 1}.");
                    guest = Pair.Value;
                    Console.WriteLine("How many days would you like to rent a room for?");
                    int      days2  = Convert.ToInt32(Console.ReadLine());
                    DateTime date1  = time.AddDays(days2);
                    decimal  topay1 = days2 * hotel[Pair.Key].Price;
                    Console.WriteLine($"To pay: {topay1}.");
                    Console.ReadKey();
                    Console.WriteLine("*money*");
                    Console.ReadKey();
                    //int paid1;
                    guest.ToRent(days2, hotel[Pair.Key]);
                    Hotel.Booked.Remove(Pair.Key);
                    break;
                }
            }
            if (guest != null)
            {
                //Console.WriteLine("Your age:");
                //int age = Convert.ToInt32(Console.ReadLine());
                //guest = new Guest(guest.Name, age);
                //tourist.Notify += DisplayMessage;
                string category;
                while (true)
                {
                    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();
                    }

                    DateTime time = DateTime.Now;
                    Console.WriteLine("How many days?");

                    int days1 = Convert.ToInt32(Console.ReadLine());
                    if (days1 <= 0)
                    {
                        throw new Exception();
                    }
                    DateTime date  = time.AddDays(days1);
                    decimal  topay = days1 * hotel[rooms[0]].Price;
                    Console.WriteLine($"To pay: {topay}.");
                    Console.ReadKey();
                    Console.WriteLine("*money*");
                    Console.ReadKey();
                    foreach (int r in rooms)
                    {
                        if (guest.ToRent(days1, hotel[r]))
                        {
                            Hotel.Booked.Add(r, guest);
                            break;
                        }
                    }
                }
            }
        }
예제 #14
0
        private static List <Hotel> AdaugaHotel(List <Hotel> list)
        {
            Hotel newHotel = new Hotel();

            list.Add(newHotel);
            Console.Write("Introdu nume hotel: ");
            newHotel.Name = Console.ReadLine();
            Console.Write("Introdu nume oras: ");
            newHotel.City = Console.ReadLine();
            Room room1 = new Room();

            newHotel.room.Add(room1);
            Console.Write("Introdu nume camera 1: ");
            newHotel.room[0].Name = Console.ReadLine();
            Console.Write("Introdu numar adulti camera 1: ");
            newHotel.room[0].Adults = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu numar copii camera 1: ");
            newHotel.room[0].Children = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu pret/noapte camera 1: ");
            newHotel.room[0].rate.Ammount  = Convert.ToInt32(Console.ReadLine());
            newHotel.room[0].rate.Currency = "$";

            Room room2 = new Room();

            newHotel.room.Add(room2);
            Console.Write("Introdu nume camera 2: ");
            newHotel.room[1].Name = Console.ReadLine();
            Console.Write("Introdu numar adulti camera 1: ");
            newHotel.room[1].Adults = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu numar copii camera 1: ");
            newHotel.room[1].Children = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu pret/noapte camera 1: ");
            newHotel.room[1].rate.Ammount  = Convert.ToInt32(Console.ReadLine());
            newHotel.room[1].rate.Currency = "$";

            Room room3 = new Room();

            newHotel.room.Add(room3);
            Console.Write("Introdu nume camera 3: ");
            newHotel.room[2].Name = Console.ReadLine();
            Console.Write("Introdu numar adulti camera 3: ");
            newHotel.room[2].Adults = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu numar copii camera 3: ");
            newHotel.room[2].Children = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu pret/noapte camera 3: ");
            newHotel.room[2].rate.Ammount  = Convert.ToInt32(Console.ReadLine());
            newHotel.room[2].rate.Currency = "$";

            Room room4 = new Room();

            newHotel.room.Add(room4);
            Console.Write("Introdu nume camera 4: ");
            newHotel.room[3].Name = Console.ReadLine();
            Console.Write("Introdu numar adulti camera 4: ");
            newHotel.room[3].Adults = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu numar copii camera 4: ");
            newHotel.room[3].Children = Convert.ToInt32(Console.ReadLine());
            Console.Write("Introdu pret/noapte camera 4: ");
            newHotel.room[3].rate.Ammount  = Convert.ToInt32(Console.ReadLine());
            newHotel.room[3].rate.Currency = "$";

            return(list);
        }
예제 #15
0
        private static List <Hotel> InitializareListaHoteluri()
        {
            List <Hotel> list   = new List <Hotel>();
            Hotel        unirea = new Hotel();

            unirea.Name = "Unirea";
            unirea.City = "Iasi";
            Room room1u = new Room();

            unirea.room.Add(room1u);
            unirea.room[0].Name          = "Camera 1";
            unirea.room[0].Adults        = 1;
            unirea.room[0].Children      = 0;
            unirea.room[0].rate.Ammount  = 40;
            unirea.room[0].rate.Currency = "$";
            Room room2u = new Room();

            unirea.room.Add(room2u);
            unirea.room[1].Name          = "Camera 2";
            unirea.room[1].Adults        = 2;
            unirea.room[1].Children      = 0;
            unirea.room[1].rate.Ammount  = 50;
            unirea.room[1].rate.Currency = "$";
            Room room3u = new Room();

            unirea.room.Add(room3u);
            unirea.room[2].Name          = "Camera 3";
            unirea.room[2].Adults        = 2;
            unirea.room[2].Children      = 1;
            unirea.room[2].rate.Ammount  = 60;
            unirea.room[2].rate.Currency = "$";
            Room room4u = new Room();

            unirea.room.Add(room4u);
            unirea.room[3].Name          = "Camera 4";
            unirea.room[3].Adults        = 2;
            unirea.room[3].Children      = 2;
            unirea.room[3].rate.Ammount  = 70;
            unirea.room[3].rate.Currency = "$";
            list.Add(unirea);
            //---------------------------------
            Hotel traian = new Hotel();

            traian.Name = "Traian";
            traian.City = "Iasi";
            Room room1t = new Room();

            traian.room.Add(room1t);
            traian.room[0].Name          = "Camera 1";
            traian.room[0].Adults        = 11;
            traian.room[0].Children      = 0;
            traian.room[0].rate.Ammount  = 35;
            traian.room[0].rate.Currency = "$";
            Room room2t = new Room();

            traian.room.Add(room2t);
            traian.room[1].Name          = "Camera 2";
            traian.room[1].Adults        = 2;
            traian.room[1].Children      = 0;
            traian.room[1].rate.Ammount  = 45;
            traian.room[1].rate.Currency = "$";
            Room room3t = new Room();

            traian.room.Add(room3t);
            traian.room[2].Name          = "Camera 3";
            traian.room[2].Adults        = 2;
            traian.room[2].Children      = 1;
            traian.room[2].rate.Ammount  = 55;
            traian.room[2].rate.Currency = "$";
            Room room4t = new Room();

            traian.room.Add(room4t);
            traian.room[3].Name          = "Camera 4";
            traian.room[3].Adults        = 2;
            traian.room[3].Children      = 2;
            traian.room[3].rate.Ammount  = 65;
            traian.room[3].rate.Currency = "$";
            list.Add(traian);
            //---------------------------------
            Hotel hilton = new Hotel();

            hilton.Name = "Hilton";
            hilton.City = "Bucuresti";
            Room room1h = new Room();

            hilton.room.Add(room1h);
            hilton.room[0].Name          = "Camera 1";
            hilton.room[0].Adults        = 1;
            hilton.room[0].Children      = 0;
            hilton.room[0].rate.Ammount  = 45;
            hilton.room[0].rate.Currency = "$";
            Room room2h = new Room();

            hilton.room.Add(room2h);
            hilton.room[1].Name          = "Camera 2";
            hilton.room[1].Adults        = 2;
            hilton.room[1].Children      = 0;
            hilton.room[1].rate.Ammount  = 55;
            hilton.room[1].rate.Currency = "$";
            Room room3h = new Room();

            hilton.room.Add(room3h);
            hilton.room[2].Name          = "Camera 3";
            hilton.room[2].Adults        = 2;
            hilton.room[2].Children      = 1;
            hilton.room[2].rate.Ammount  = 65;
            hilton.room[2].rate.Currency = "$";
            Room room4h = new Room();

            hilton.room.Add(room4h);
            hilton.room[3].Name          = "Camera 4";
            hilton.room[3].Adults        = 2;
            hilton.room[3].Children      = 2;
            hilton.room[3].rate.Ammount  = 75;
            hilton.room[3].rate.Currency = "$";
            list.Add(hilton);
            return(list);
        }
예제 #16
0
 private Room CheckIfRoomExists(int?roomId, Hotel hotel)
 {
     return(hotel.Rooms.Where(x => x.Id == roomId)
            .FirstOrDefault());
 }
예제 #17
0
        public Tuple <string, int, int, string> BookFirstAvailableRoom(Tuple <int, int> days, Hotel hotel, bool checkDays = false)
        {
            string status = "Declined";

            if (checkDays = true && !ValidateInputDays(days.Item1, days.Item2))
            {
                return(PrintBooking(hotel.BookingId++, days, "Declined"));
            }

            foreach (var room in hotel.Rooms)
            {
                status = ResolveReservation(room, days);

                if (status == "Accepted")
                {
                    break;
                }
            }

            return(PrintBooking(hotel.BookingId++, days, status));
        }
        private static void Main()
        {
            #region Lab1-2-3-4-5-6-7

            #region Lab1-2-3

            Console.WriteLine("\n--------Lab1-2-3--------");
            Hotel RedHotel = new Hotel(1, "Адам", "вул. Т. Шевченка",
                                       "Дуже крутий опис дуже крутого готелю, який всім дуже " +
                                       "подобається")
            {
                City          = City.Kyiv,
                Rating        = 32,
                NumberOfStars = 3
            };

            User AdminV = new User(1, 2, "AdminValera", "*****@*****.**",
                                   "+069069696");

            RedHotel.CreateRoom(2, 2, "Red", 1, RedHotel, true, "Big", 5, true);

            RedHotel.CreateOrder(1, 300, RedHotel, AdminV, "1", RedHotel.Rooms[0],
                                 DateTime.Now, DateTime.Now.AddDays(7));

            ConcreteOrder order = new ConcreteOrder(2, 300, RedHotel, AdminV,
                                                    "2", RedHotel.Rooms[1],
                                                    DateTime.Now, DateTime.Now.AddDays(7))
            {
                DateStart = DateTime.Parse("22.01.2002")
            };

            // Constructor by default
            User GreatValeera = new User
            {
                UserName = "******"
            };

            // Copy Constructor
            User GreaterValeera = new User(GreatValeera);

            #endregion Lab1-2-3

            #region Lab4

            Console.WriteLine("\n--------Lab4--------");

            #region Unary

            Console.WriteLine("\n--Перевантаження унарних операторiв:--\n");

            Console.WriteLine($"Кiлькiсть зiрок: {RedHotel.NumberOfStars}");
            ++RedHotel;
            Console.WriteLine($"Кiлькiсть зiрок пiсля збiльшення:" +
                              $" {RedHotel.NumberOfStars}");
            --RedHotel;
            Console.WriteLine($"Кiлькiсть зiрок пiсля зменшення:" +
                              $" {RedHotel.NumberOfStars}");

            Console.WriteLine();

            Console.WriteLine($"Кiлькiсть лiжок: {RedHotel.Rooms[0].NumberOfBeds}");
            ++RedHotel.Rooms[0];
            Console.WriteLine($"Кiлькiсть зiрок пiсля збiльшення:" +
                              $" {RedHotel.Rooms[0].NumberOfBeds}");
            --RedHotel.Rooms[0];
            Console.WriteLine($"Кiлькiсть зiрок пiсля зменшення:" +
                              $" {RedHotel.Rooms[0].NumberOfBeds}");

            #endregion Unary

            #region Binary

            Console.WriteLine("\n--Перевантаження бiнарних операторiв:--\n");

            Console.WriteLine("Iм'я першої кiмнати = "
                              + RedHotel.Rooms[0].RoomName);
            Console.WriteLine("Iм'я другої кiмнати = "
                              + RedHotel.Rooms[1].RoomName);

            Console.WriteLine($"Розмiр першої кiмнати = " +
                              $"{RedHotel.Rooms[0].RoomSize}\nРозмiр другої " +
                              $"кiмнати = {RedHotel.Rooms[1].RoomSize}\n");

            Room newRoom = RedHotel.Rooms[0] + RedHotel.Rooms[1];

            Console.WriteLine("Iм'я нової першої кiмнати = "
                              + RedHotel.Rooms[0].RoomName);

            Console.WriteLine($"Розмiр нової, об'єднаної кiмнати = " +
                              $"{newRoom.RoomSize}");

            #endregion Binary

            #region Logical

            Console.WriteLine("\n--Перевантаження логiчних операторiв:--\n");

            if (RedHotel)
            {
                Console.WriteLine("Рейтинг додатнiй");
            }

            RedHotel.Rating = 23;
            if (!RedHotel)
            {
                Console.WriteLine("Рейтинг вiд'ємний");
            }

            Console.WriteLine();

            if (order)
            {
                Console.WriteLine("Замовлення ще активне");
            }

            order.DateEnd = DateTime.Parse("22.01.2002");
            if (!order)
            {
                Console.WriteLine("Замовлення вже не активне");
            }

            Console.WriteLine();

            if (AdminV)
            {
                Console.WriteLine("Користувач має пошту та телефон");
            }

            GreatValeera.UserMail    = "*****@*****.**";
            GreaterValeera.UserMail  = "*****@*****.**";
            GreatValeera.UserPhone   = "+069069696";
            GreaterValeera.UserPhone = "+069069696";

            if (GreatValeera & GreaterValeera)
            {
                Console.WriteLine("Користувачi мають пошту та телефон");
            }

            #endregion Logical

            #region Comparison

            Console.WriteLine("\n--Перевантаження операторiв порiвняння:--\n");

            Hotel BlueHotel = new Hotel(2, "Єва", "вул. Т. Шевченка",
                                        "Не дуже крутий опис не дуже крутого готелю, який не всiм не дуже " +
                                        "не подобається")
            {
                City          = City.Kyiv,
                Rating        = 32,
                NumberOfStars = 3
            };

            BlueHotel.CreateRoom(2, 2, "Blue", 5, BlueHotel, false, "Big", 15, true);

            Console.WriteLine($"Кiлькiсть зiрок, рейтинг Готелю " +
                              $"1: {RedHotel.NumberOfStars}, {RedHotel.Rating}");
            Console.WriteLine($"Кiлькiсть зiрок, рейтинг Готелю " +
                              $"2: {BlueHotel.NumberOfStars}, {BlueHotel.Rating}");

            Console.WriteLine($"Перевiряємо рiвнозначнiсть Готелю 1 " +
                              $"та Готелю 2: {RedHotel == BlueHotel}");
            Console.WriteLine($"Перевiряємо нерiвнозначнiсть Готелю 1 " +
                              $"та Готелю 2: {RedHotel != BlueHotel}");
            Console.WriteLine();

            Console.WriteLine($"Кiлькiсть лiжок, розмiр, наявнiсть" +
                              $" телевiзора та балкону в Кiмнатi 1: " +
                              $"{RedHotel.Rooms[0].NumberOfBeds}, " +
                              $"{RedHotel.Rooms[0].RoomSize}, {RedHotel.Rooms[0].TV}," +
                              $" {RedHotel.Rooms[0].Balcony}");
            Console.WriteLine($"Кiлькiсть лiжок, розмiр, наявнiсть" +
                              $" телевiзора та балкону в Кiмнатi 2: " +
                              $"{BlueHotel.Rooms[0].NumberOfBeds}, " +
                              $"{BlueHotel.Rooms[0].RoomSize}, {BlueHotel.Rooms[0].TV}, " +
                              $"{BlueHotel.Rooms[0].Balcony}");

            Console.WriteLine($"Перевiряємо рiвнозначнiсть Кiмнати 1 та " +
                              $"Кiмнати 2: {RedHotel.Rooms[0] == BlueHotel.Rooms[0]}");
            Console.WriteLine($"Перевiряємо нерiвнозначнiсть Кiмнати 1 та " +
                              $"Кiмнати 2: {RedHotel.Rooms[0] != BlueHotel.Rooms[0]}");

            #endregion Comparison

            #endregion Lab4

            #region Lab5

            Console.WriteLine("\n--------Lab5--------");

            #region Base-Classes-And-Inheritence

            Console.WriteLine("\n--Базовi та похiднi класи:--");

            Console.WriteLine("\nСтворюємо вiдвiдувача:");
            Customer Customer = new Customer(7,
                                             "*****@*****.**", "Genji", "+067069696");

            Console.WriteLine("\nСтворюємо адмiна:");
            Admin Admin = new Admin(8, "*****@*****.**",
                                    "Hanzo", "+069069698");

            #endregion Base-Classes-And-Inheritence

            #region Abstract-Classes-And-Virtual-Methods

            Console.WriteLine("\n--Абстрактнi класи та вiртуальнi методи:--");

            Console.WriteLine("\nВикористовуємо перший override конструктор:");

            NotSoConcreteOrder NotSoConcreteOrder = new NotSoConcreteOrder(50,
                                                                           666, BlueHotel, Admin, "3", BlueHotel.Rooms[0],
                                                                           DateTime.Now, DateTime.Now.AddDays(7));

            Console.WriteLine("\nВикористовуємо другий override конструктор:");

            ConcreteOrder ConcreteOrder = new ConcreteOrder(51,
                                                            667, BlueHotel, Customer, "4", BlueHotel.Rooms[1],
                                                            DateTime.Now, DateTime.Now.AddDays(7));

            Console.WriteLine("\nВикористовуємо перший override метод:");

            NotSoConcreteOrder.IsExpired();

            Console.WriteLine("\nВикористовуємо перший не override метод:");

            ConcreteOrder.IsExpired();

            Console.WriteLine("\nВикористовуємо другий override метод:");

            NotSoConcreteOrder.BelongsTo();

            Console.WriteLine("\nВикористовуємо другий не override метод:");

            ConcreteOrder.BelongsTo();

            #endregion Abstract-Classes-And-Virtual-Methods

            #region Interface

            Console.WriteLine("\n--Iнтерфейси:--");

            Console.WriteLine("\nСтворюємо готель через iнтерфейс:");

            IRoom greenHotel = new Hotel(4, "GreenDeer", "вул. Т. Шевченка",
                                         "Myyyyyyyyyyyyyyyyy Myyyyyyyyyyyyyyyyy " +
                                         "Myyyyyyyyyyyyyyyyy Myyyyyyyyyyyyyyyyy Myyyyyyyyyyyyyyyyy")
            {
                City          = City.Kyiv,
                Rating        = 12,
                NumberOfStars = 5
            };

            greenHotel.CreateRoom(2, 2, "aZUL", 1, (Hotel)greenHotel
                                  , true, "Big", 5, true); // Downcasting

            #endregion Interface

            #region Upcast, Downcast

            Console.WriteLine("\n--Upcast та Downcast:--");

            // Upcast
            Customer customer = new Customer(7,
                                             "*****@*****.**", "Genji", "+067069696");
            Admin admin = new Admin(8,
                                    "*****@*****.**", "Hanzo", "+069069698");

            User customerUser = customer;
            User adminUser    = admin;

            Console.WriteLine("\n--Показуємо типи об'єктiв" +
                              " пiсля Upcast:--");

            Console.WriteLine(customerUser.GetType());
            Console.WriteLine(adminUser.GetType());
            Customer customer1 = (Customer)customerUser;
            Admin    admin1    = (Admin)adminUser;

            Console.WriteLine("\n--Показуємо властивостi " +
                              "об'єктiв пiсля Downcast:--");

            Console.WriteLine(customer1.UserTypeName);
            Console.WriteLine(admin1.UserTypeName);

            #endregion Upcast, Downcast

            #endregion Lab5

            #region Lab6

            Console.WriteLine("\n--------Lab6--------");

            #region Events

            Console.WriteLine("\n--Подiї:--\n");

            Hotel EventHotel = new Hotel(56, "Подiя", "вул. Т. Шевченка",
                                         "Дуже крутий опис дуже крутого готелю, який всім дуже " +
                                         "подобається")
            {
                City          = City.Kyiv,
                Rating        = 35,
                NumberOfStars = 4
            };

            EventHotel.EventForNotifying += DisplayMessage;

            EventHotel.CreateRoom(2, 2, "Подiя", 1, EventHotel, true, "Big", 5, true);

            #endregion Events

            #region Anonymous-Methods

            Console.WriteLine("\n--Анонiмнi методи:--\n");

            Room.ShowSomeString("1. Анонiмний метод класу Room.", delegate(string messageString)
            {
                Console.WriteLine(messageString);
            });

            Hotel.ShowSomeString("2. Анонiмний метод класу Hotel.", delegate(string messageString)
            {
                Console.WriteLine(messageString);
            });

            #endregion Anonymous-Methods

            #region Lambda

            Console.WriteLine("\n--Лямбди:--\n");

            Console.WriteLine("Коефiцiєнт просторностi кiмнати: "
                              + RedHotel.Rooms[0].SpaceKoeff);

            RedHotel.Rooms[0].CheckHotelPrice(x => DateTime.Now.DayOfWeek
                                              != DayOfWeek.Sunday);

            decimal priceOne()
            {
                return(order.Room.NumberOfBeds == 0 ? 1
                    : order.Sum / order.Room.NumberOfBeds);
            }

            Console.WriteLine("Цiна за одну людину в кiмнатi: " + priceOne());

            #endregion Lambda

            #endregion Lab6

            #region Lab7

            Console.WriteLine("\n--------Lab7--------");

            #region Authorization

            Console.WriteLine("\n--Винятки авторизацiї:--\n");

            AdminV.Login    = "******";
            AdminV.Password = "******";

            //обробка неправильного логіну
            ShowAuthException(AdminV, "Valera9", "Valerchikperchik6");

            //обробка пустого паролю
            ShowAuthException(AdminV, "Valera96", "");

            //обробка пустого логіну
            ShowAuthException(AdminV, "", "Valerchikperchik69");

            //коректний логін
            ShowAuthException(AdminV, "Valera96", "Valerchikperchik69");

            #endregion Authorization

            #region Filters-And-Arrays

            Console.WriteLine("\n--Робота з фiльтрами та масивами:--\n");

            Additional.Additional.Lab7();

            #endregion Filters-And-Arrays

            #region SystemExceptions

            Console.WriteLine("\n--Системнi винятки:--\n");

            object      stacks = "twelve";
            List <User> users  = null;
            var         users2 = new List <string>();

            // InvalidCastException
            try
            {
                int KelThuzad = (int)stacks;
                Console.WriteLine("Cast is success");
            }
            catch (InvalidCastException)
            {
                Console.WriteLine("Catched casting exception");
            }

            // ArgumentException
            try
            {
                if (stacks != "+069069698")
                {
                    throw new ArgumentException();
                }
                Console.WriteLine("Argument is good");
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Catched argument exception");
            }

            // NullReferenceException
            try
            {
                users.Add(GreatValeera);
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Catched null reference exception");
            }

            // ArgumentOutOfRangeException
            try
            {
                Console.WriteLine("The first item: '{0}'", users2[0]);
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.WriteLine("Catched argument out of range exception");
            }

            #endregion SystemExceptions

            #region CustomExceptions

            Console.WriteLine("\n--Власнi винятки:--\n");

            try
            {
                throw new Metaclass();
            }
            catch (Metaclass e)
            {
                Console.WriteLine("Обработка исключения:");
                e.MetaMethod();
            }

            #endregion CustomExceptions

            #endregion Lab7

            #endregion Lab1-2-3-4-5-6-7

            #region Lab8

            Console.WriteLine("\n--------Lab8--------");

            #region Lab8-1

            Console.WriteLine("\n--4.1:--\n");

            DateTime startTime1 = DateTime.Now;
            Additional.Additional.Count1();
            DateTime endTime1 = DateTime.Now;
            TimeSpan diff1    = endTime1 - startTime1;

            Console.WriteLine("Час виконання (один потiк):");
            Console.WriteLine(diff1.TotalMilliseconds);

            DateTime startTime2 = DateTime.Now;
            Additional.Additional.First().Start();
            DateTime endTime3 = DateTime.Now;
            Additional.Additional.Second().Start();
            DateTime endTime4 = DateTime.Now;

            TimeSpan diff2     = endTime3 - startTime2;
            TimeSpan diff4     = endTime4 - endTime3;
            TimeSpan totalDiff = endTime4 - startTime2;

            Console.WriteLine($"Час виконання (окремi потоки): " +
                              $"\n{diff2.TotalMilliseconds}" +
                              $"\n{diff4.TotalMilliseconds} \nЗагальний " +
                              $"час - {totalDiff.TotalMilliseconds}");

            #endregion Lab8-1

            #region Lab8-2

            Console.WriteLine("\n--4.2:--\n");

            Zone.Lab8_2();

            Thread.Sleep(1000);

            #endregion Lab8-2

            #region Lab8-3

            Console.WriteLine("\n--4.3:--\n");

            Additional.Additional.Lab8_3();

            Thread.Sleep(1000);

            #endregion Lab8-3

            #region Lab8-4

            Console.WriteLine("\n--4.4:--\n");

            Additional.Additional.Lab8_4();

            Thread.Sleep(1000);

            #endregion Lab8-4

            #endregion Lab8

            Console.WriteLine("\n--------Credits-------");

            Console.WriteLine("\nFirst Team: Zavalniuk Maxim," +
                              "\nDmytrenko Roman,\n" +
                              "Sichkar Tetiana,\nDominskyi Valentyn");

            Console.ReadLine();
        }
예제 #19
0
        static void Main(string[] args)
        {
            string linea, name, id, room, destiny, price;
            int    opcion;
            Hotel  reg = new Hotel();
            Viajes via = new Viajes();

            do
            {
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("MENU DE OPCIONES");
                Console.WriteLine("1. Registrar clientes");
                Console.WriteLine("2. Registrar viajes");
                Console.WriteLine("3. Imprimir directorio clientes");
                Console.WriteLine("4. Imprimir listado viajes");
                Console.WriteLine("5. Consulta de un cliente");
                Console.WriteLine("6. Modificar valor de un viaje");
                Console.WriteLine("7. SALIR");
                Console.WriteLine("");
                linea  = Console.ReadLine();
                opcion = int.Parse(linea);
                switch (opcion)
                {
                case 1:
                    Console.WriteLine("");
                    Console.WriteLine("Digite nombre del cliente");
                    name = Console.ReadLine();
                    Console.WriteLine("");
                    Console.WriteLine("Digite numero de documento del cliente");
                    id = Console.ReadLine();
                    Console.WriteLine("");
                    Console.WriteLine("Digite numero de la habitacion donde se hospedara el cliente");
                    room = Console.ReadLine();
                    reg.Registrar(name, id, room);
                    break;

                case 2:
                    Console.WriteLine("");
                    Console.WriteLine("Digite el destino");
                    destiny = Console.ReadLine();
                    Console.WriteLine("");
                    Console.WriteLine("Digite el valor");
                    price = Console.ReadLine();
                    via.RegistrarDestino(destiny, price);
                    break;

                case 3:
                    reg.ListarClientes();
                    break;

                case 4:
                    via.ListarDestinos();
                    break;

                case 5:
                    Console.WriteLine("");
                    Console.WriteLine("Digite el numero de cedula que desea consultar");
                    id = Console.ReadLine();
                    reg.ConsultarClientes(id);
                    break;

                case 6:
                    Console.WriteLine("");
                    Console.WriteLine("Digite el destino para modificar el precio");
                    destiny = Console.ReadLine();
                    via.EditarPrecio(destiny);
                    break;
                }
            } while (opcion != 7);
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Saliendo del programa");
        }
예제 #20
0
        public Tuple <string, int, int, string> BookARoom(int?roomId, Tuple <int, int> startEndDays, Hotel hotel)
        {
            if (!ValidateInputDays(startEndDays.Item1, startEndDays.Item2))
            {
                return(PrintBooking(hotel.BookingId++, startEndDays, "Declined"));
            }

            if (roomId != null)
            {
                var room = CheckIfRoomExists(roomId, hotel);
                if (room == null)
                {
                    return(PrintBooking(hotel.BookingId++, startEndDays, "Declined (Room with this Id does not exist)"));
                }

                return(PrintBooking(hotel.BookingId++, startEndDays, ResolveReservation(room, startEndDays)));
            }

            return(BookFirstAvailableRoom(startEndDays, hotel));
        }