Example #1
0
 public Guest(string n, string ppn, Stay s, Membership m, bool i) //word doc didnt state to put in the bool, so i left it out. not sure if thats right or wrong.
 {
     name        = n;
     ppNumber    = ppn;
     hotelStay   = s; // is HotelStay and Membership correct? It's supposed to be both capital just like in public Stay HotelStay
     membership  = m;
     isCheckedIn = i;
 }
        public void InitData() //create room objects
        {
            //standard room objects
            HotelRoom room1 = new StandardRoom("Standard", "101", "Single", 90, false, 2);
            HotelRoom room2 = new StandardRoom("Standard", "102", "Single", 90, true, 2);
            HotelRoom room3 = new StandardRoom("Standard", "201", "Twin", 110, true, 4);
            HotelRoom room4 = new StandardRoom("Standard", "202", "Twin", 110, false, 4);
            HotelRoom room5 = new StandardRoom("Standard", "203", "Twin", 110, true, 4);
            HotelRoom room6 = new StandardRoom("Standard", "301", "Triple", 120, true, 6);
            HotelRoom room7 = new StandardRoom("Standard", "302", "Triple", 120, false, 6);
            //deluxe room objects
            HotelRoom room8  = new DeluxeRoom("Deluxe", "204", "Twin", 140, true, 4);
            HotelRoom room9  = new DeluxeRoom("Deluxe", "205", "Twin", 140, true, 4);
            HotelRoom room10 = new DeluxeRoom("Deluxe", "303", "Triple", 210, false, 6);
            HotelRoom room11 = new DeluxeRoom("Deluxe", "304", "Triple", 210, true, 6);

            //adding to hotelList
            hotelList.Add(room1);
            hotelList.Add(room2);
            hotelList.Add(room3);
            hotelList.Add(room4);
            hotelList.Add(room5);
            hotelList.Add(room6);
            hotelList.Add(room7);
            hotelList.Add(room8);
            hotelList.Add(room9);
            hotelList.Add(room10);
            hotelList.Add(room11);

            //first guest information
            Stay             s1        = new Stay(Convert.ToDateTime("26-Jan-2019"), Convert.ToDateTime("02-Feb-2019"));
            List <HotelRoom> roomList1 = s1.RoomList;

            s1.AddRoom(room1);
            Membership m1 = new Membership("Gold", 280);
            Guest      g1 = new Guest("Amelia", "S1234567A", s1, m1, true);
            //second guest information
            Stay             s2        = new Stay(Convert.ToDateTime("25-Jan-2019"), Convert.ToDateTime("31-Jan-2019"));
            List <HotelRoom> roomList2 = s2.RoomList;

            s2.AddRoom(room7);
            Membership m2 = new Membership("Ordinary", 0);
            Guest      g2 = new Guest("Bob", "G1234567A", s2, m2, true);
            //third guest information
            Stay             s3        = new Stay(Convert.ToDateTime("01-Feb-2019"), Convert.ToDateTime("06-Feb-2019"));
            List <HotelRoom> roomList3 = s3.RoomList;

            s3.AddRoom(room4);
            Membership m3 = new Membership("Silver", 190);
            Guest      g3 = new Guest("Cody", "G234567A", s3, m3, true);
            //fourth guest information
            Stay             s4        = new Stay(Convert.ToDateTime("28-Jan-2019"), Convert.ToDateTime("10-Feb-2019"));
            List <HotelRoom> roomList4 = s4.RoomList;

            s4.AddRoom(room10);
            Membership m4 = new Membership("Gold", 10);
            Guest      g4 = new Guest("Edda", "S3456789A", s4, m4, true);

            //adding guest objects into guestList
            guestList.Add(g1);
            guestList.Add(g2);
            guestList.Add(g3);
            guestList.Add(g4);


            StandardRoom srroom101 = (StandardRoom)room1;

            srroom101.RequireWifi      = true;
            srroom101.RequireBreakfast = true;

            StandardRoom srroom302 = (StandardRoom)room7;

            srroom101.RequireBreakfast = true;

            StandardRoom srroom202 = (StandardRoom)room4;

            srroom202.RequireBreakfast = true;

            DeluxeRoom srroom303 = (DeluxeRoom)room10;

            srroom303.AdditionalBed = true;
        }
        } //updates the listview

        private void checkInBtn_Click(object sender, RoutedEventArgs e)
        {
            bool check = false;

            foreach (Guest g in guestList)
            {
                if (guestTxt.Text != g.Name)
                {
                    check = true;
                }
            }
            if (passportTxt.Text == "" || passportTxt.Text == " ")
            {
                statusUpdateText.Text = "Please enter a Passport Number";
            }
            else
            {
                if (check == true)                                                                                                                      //if guest.text cannot be found in the guestList.Name
                {
                    Stay       s     = new Stay(DateTime.Parse(checkInDatePicker.Date.ToString()), DateTime.Parse(checkOutDatePicker.Date.ToString())); //get datestart and dateend
                    Membership m     = new Membership("Ordinary", 0);
                    Guest      guest = new Guest(guestTxt.Text, passportTxt.Text, s, m, false);                                                         //create guest info 1:1
                    guestList.Add(guest);                                                                                                               //add into guestList
                    string roomscheckedin = "";
                    for (var i = 0; i < tempRoomList.Count; i++)
                    {
                        HotelRoom r = tempRoomList[i];
                        r.IsAvail       = false;
                        r.NoOfOccupants = Convert.ToInt32(noOfAdultTxt.Text) + Convert.ToInt32(noOfChildrentxt.Text);
                        if (r.RoomType == "Standard")
                        {
                            HotelRoom h         = new StandardRoom(r.RoomType, r.RoomNumber, r.BedConfiguration, r.DailyRate, r.IsAvail, r.NoOfOccupants);
                            int       noOfGuest = (Convert.ToInt32(noOfAdultTxt.Text) / 2) + (Convert.ToInt32(noOfChildrentxt.Text));
                            if (noOfGuest <= r.NoOfOccupants)
                            {
                                s.AddRoom(h);
                            }
                            else
                            {
                                statusUpdateText.Text = "Add an Additional Bed\nOr Change Your Selected Choice";
                            }
                        }
                        else if (r.RoomType == "Deluxe")
                        {
                            HotelRoom h         = new DeluxeRoom(r.RoomType, r.RoomNumber, r.BedConfiguration, r.DailyRate, r.IsAvail, r.NoOfOccupants);
                            int       noOfGuest = (Convert.ToInt32(noOfAdultTxt.Text) / 2) + (Convert.ToInt32(noOfChildrentxt.Text));
                            if (noOfGuest < r.NoOfOccupants)
                            {
                                s.AddRoom(h);
                            }
                            else
                            {
                                statusUpdateText.Text = "Add an Additional Bed\nOr Change Your Selected Choice";
                            }
                        }
                        List <HotelRoom> roomList         = s.RoomList;
                        string           guestStayDetails = "";
                        foreach (HotelRoom room in roomList)
                        {
                            guestStayDetails += room.ToString() + guest.ToString();
                        }
                        roomsBookedTxt.Text = guestStayDetails;
                        roomscheckedin     += r.RoomNumber.ToString() + " ";
                    }
                    tempRoomList.Clear(); //clears the selected room list
                    RefreshList();        //refreshes room list [2.1.5]
                    statusUpdateText.Text = "Status update: Rooms" + " " + roomscheckedin + "checked in successfully.";
                    roomscheckedin        = "";
                }
                else if (check == false)                         //existing guest code goes here [2.1.6]
                {
                    for (var i = 0; i < tempRoomList.Count; i++) //loops thru the tempRoomList
                    {
                        HotelRoom r = tempRoomList[i];
                        r.IsAvail       = false;                                                                      //sets every room isAvail to false
                        r.NoOfOccupants = Convert.ToInt32(noOfAdultTxt.Text) + Convert.ToInt32(noOfChildrentxt.Text); //calculates total number of occupants
                        if (r.RoomType == "Standard")                                                                 //checks if the room is standard. if it is, create a standard room object
                        {
                            HotelRoom h = new StandardRoom(r.RoomType, r.RoomNumber, r.BedConfiguration, r.DailyRate, r.IsAvail, r.NoOfOccupants);
                            foreach (Guest g in guestList)
                            {
                                if (g.Name == guestTxt.Text)
                                {
                                    int noOfGuest = (Convert.ToInt32(noOfAdultTxt.Text) / 2) + (Convert.ToInt32(noOfChildrentxt.Text));
                                    if (noOfGuest <= r.NoOfOccupants)
                                    {
                                        g.HotelStay.AddRoom(h); //add it into the guest.RoomList
                                    }
                                    else
                                    {
                                        statusUpdateText.Text = "Add an Additional Bed\nOr Change Your Selected Choice";
                                    }
                                }
                            }
                        }
                        else if (r.RoomType == "Deluxe") //checks if the room is deluxe. if it is, create a deluxe room object
                        {
                            HotelRoom h = new DeluxeRoom(r.RoomType, r.RoomNumber, r.BedConfiguration, r.DailyRate, r.IsAvail, r.NoOfOccupants);
                            foreach (Guest g in guestList)
                            {
                                if (g.Name == guestTxt.Text)
                                {
                                    int noOfGuest = (Convert.ToInt32(noOfAdultTxt.Text) / 2) + (Convert.ToInt32(noOfChildrentxt.Text));
                                    if (noOfGuest < r.NoOfOccupants)
                                    {
                                        g.HotelStay.AddRoom(h);  //add it into the guest.RoomList
                                    }
                                    else
                                    {
                                        statusUpdateText.Text = "Add an Additional Bed\nOr Change Your Selected Choice";
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }