예제 #1
0
 public BedRoomVM(BedRoom bedRoom)
 {
     ID         = bedRoom.ID;
     RoomNumber = bedRoom.RoomNumber;
     RoomType   = bedRoom.roomType.ToString();
 }
예제 #2
0
        private bool GenAbstractionFromAccomProfile(int maxguests, int numBedrooms)
        {
            try
            {
                int SingleBed = 0;
                int DoubleBed = 0;

                int            MaxGuests      = maxguests;
                int            maxGuests      = maxguests;
                int            NumberBedRooms = numBedrooms;
                List <BedRoom> bedRooms       = new List <BedRoom>();
                for (int i = 0; i < NumberBedRooms; i++)
                {
                    BedRoom bdRoom = new BedRoom(0, 1, i + 1);
                    bedRooms.Add(bdRoom);
                    maxGuests -= 2;
                    DoubleBed += 1;
                }
                if (maxGuests > 0) //At least 1 SingleBed + DoubleBed
                {
                    SingleBed = maxGuests;
                    int whileCounter = 0;
                    while (maxGuests > 0)
                    {
                        if (whileCounter > 30)
                        {
                            throw new Exception("WhileCounter Exception at Room Init, Failed to init Accomodation ", new ArgumentException());
                        }
                        foreach (var room in bedRooms)
                        {
                            if (maxGuests > 0)
                            {
                                room.SingleBeds++;
                                room.MaxGuests++;
                                maxGuests--;
                            }
                        }
                        whileCounter++;
                    }
                }
                else
                {
                    if (maxGuests < 0) //Some rooms have only singlebeds, will only run once
                    {
                        int whileCounter = 0;
                        while (maxGuests < 0)
                        {
                            if (whileCounter > 20)
                            {
                                throw new Exception("WhileCounter Exception at Room Init", new ArgumentException());
                            }
                            foreach (var room in bedRooms)
                            {
                                if (maxGuests < 0)
                                {
                                    DoubleBed--;
                                    SingleBed++;
                                    room.DoubleBeds--;
                                    room.SingleBeds++;
                                    room.MaxGuests--;
                                    maxGuests++;
                                }
                            }
                            whileCounter++;
                        }
                    }
                }

                if (maxGuests != 0 || DoubleBed < 0 || DoubleBed > MaxGuests / 2 || SingleBed < 0 || SingleBed > MaxGuests)
                {
                    throw new Exception("Room InitException: MaxGuests " + maxGuests + " DoubleBeds " + DoubleBed + "SingleBeds " + SingleBed, new ArgumentException());
                }
                foreach (var room in bedRooms)
                {
                    if (room.DoubleBeds < 0 || room.SingleBeds < 0)
                    {
                        throw new Exception("Room InitException: " + room.DoubleBeds + " DoubleBed " + room.SingleBeds + " SingleBed", new ArgumentException());
                    }
                    else
                    {
                        room.DetRoomType(); // determines Final roomType
                    }
                }

                Capacity = new Capacity(SingleBed, DoubleBed, NumberBedRooms, MaxGuests);
                BedRooms = bedRooms;
                return(true);
            }catch (Exception e)
            {
                NotificationManager.AddException(e);
                return(false);
            }
        }