Пример #1
0
        /// <summary>
        /// hotel add process for administrator
        /// </summary>
        /// <param name="cityName"> the city where the hotel will be located</param>
        /// <param name="star">star of hotel</param>
        /// <param name="name">name of hotel</param>
        /// <returns>transaction status</returns>
        public bool addHotel(string cityName, int star, string name)
        {
            if (!name.All(c => Char.IsLetter(c) || c == ' ') || name.Equals(""))
            {
                return(false);
            }

            foreach (Hotel item in app.hotels)
            {
                if (item.Name.Equals(name) && item.Star == star && item.City.Equals(cityName.ToUpper()))
                {
                    return(false);
                }
            }

            app.hotels.Add(HotelFactory.GetHotel(star, cityName.ToUpper(), name));
            return(true);
        }
Пример #2
0
        /// <summary>
        /// auto adds hotels
        /// default 30 otel and random Rooms
        /// </summary>
        private void firstBoot()
        {
            //added default instance
            hotels = new List <Hotel>();
            users  = new List <User>();
            admin  = Administration.getInstance("admin1", "password1", "Mustafa Firat", "YILMAZ", "21");
            users.Add(new User("user001", "password001", "name", "surname", "99"));
            users.Add(new User("user002", "password002", "name", "surname", "99"));
            users.Add(new User("user003", "password003", "name", "surname", "99"));
            users.Add(new User("user004", "password004", "name", "surname", "99"));
            users.Add(new User("user005", "password005", "name", "surname", "99"));

            int    n = 1;
            string defaultHotelName = "Hotel" + n;

            //added hotel
            Random random = new Random();
            int    k;
            string type = null;

            string[] data = { "ISTANBUL", "CANAKKALE", "IZMIR", "KOCAELI", "ANKARA", "ANTALYA", "MUGLA", "VAN", "KARS", "ESKISEHIR" };
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    k    = random.Next(1, 6);
                    type = null;

                    switch (k)
                    {
                    case 1:
                    {
                        type = "Hostel";
                        break;
                    }

                    case 2:
                    {
                        type = "BoutiqueHotel";
                        break;
                    }

                    case 3:
                    {
                        type = "AllInHotel";
                        break;
                    }

                    case 4:
                    {
                        type = "HolidayVillage";
                        break;
                    }

                    case 5:
                    {
                        type = "UltraLuxuryHotel";
                        break;
                    }
                    }
                    hotels.Add(HotelFactory.GetHotel(type, data[i], defaultHotelName));

                    n++;
                    defaultHotelName = "Hotel" + n;
                }
            }
            //added Rooms
            for (int i = 0; i < hotels.Count; i++)
            {
                addRoom(hotels[i]);
            }
        }