Пример #1
0
        public void ReservationRoomBuilder(string roomType, int noOfGuest, string promo)
        {
            if (_reservationValidator.ValidateRoomType(roomType))
            {
                _reservation.SetReservationItem("RoomType", roomType);
            }
            else
            {
                _flag  = false;
                _error = "ERROR: Invalid Room Type Input!";
            }

            // Check if there is a Promo Code given
            if (promo != "")
            {
                // Check if the Promo Code given is valid
                if (_reservationValidator.ValidatePromo(promo))
                {
                    _reservation.SetReservationItem("Promo", promo);
                    _reservation.SetReservationItem("Price", _reservationValidator.GetDiscountPrice(roomType, _days, promo));
                }
                else
                {
                    _flag  = false;
                    _error = "ERROR: Invalid Promo Code!";
                }
            }
            else
            {
                _reservation.SetReservationItem("Promo", promo);
                _reservation.SetReservationItem("Price", _reservationValidator.GetRoomPrice(roomType, _days));
            }

            // Check if Number of Guest does not exceed the Room Capacity or is below 0
            if (_reservationValidator.RoomTypeToGuestNum(roomType, noOfGuest))
            {
                _reservation.SetReservationItem("NoOfGuest", noOfGuest);
            }
            else
            {
                _flag  = false;
                _error = "ERROR: Room type:" + roomType + " cannot fit " + noOfGuest + " guests!";
            }
        }