EDIT: See Second Post
Basically I am trying to create a program that allows someone to check in new guests to rooms that are available.
This is what I have so far to create my guests and rooms and add the rooms to a list.
I am wanting to know how I can loop through each room in the "AllRooms" List and check whether its property of booked is true or false and check the room type against a combobox which has the 5 types of room in and then display all the room numbers that are not booked and are of that room type in a list box on the right hand side - See screenshot of design. All help appreciated.
Room Types are: Single Room, Double Room, Queen Suite, King Suite, Penthouse Suite
RoomClass
GuestClassCode:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Hotel_Check_In { public class Room { public static List<Room> AllRooms; public int RoomNumber { get { return this.RoomNumber; } set { this.RoomNumber = value; } } public string RoomType { get { return this.RoomType; } set { this.RoomType = value; } } public Boolean booked { get { return this.booked; } set { this.booked = value; } } public Room(int roomNumber) { RoomNumber = roomNumber; //adds room Number to room number property } public Room(int roomNumber, string roomType) { RoomNumber = roomNumber; RoomType = roomType; } public void AddRooms(int noOfRooms, string roomType) //Add new Rooms (method for adding rooms to list on load) { if (AllRooms.Count == 0) //check if any rooms exist already { for (int i = 1; i <= noOfRooms; i++) { Room newRoom = new Room(i); AllRooms.Add(newRoom); newRoom.RoomType = roomType; newRoom.booked = false; } } else { for (int i = AllRooms.Count + 1; i <= noOfRooms; i++) //if rooms exist then +1 onto current room total so no room has the same number { Room newRoom = new Room(i); AllRooms.Add(newRoom); newRoom.RoomType = roomType; newRoom.booked = false; } } } } }
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Hotel_Check_In { public class Guest { public string Name {get {return this.Name;} set {this.Name = value;}} public int rNumber {get {return this.rNumber;} set {this.rNumber = value;}} public DateTime arrivalDateTime { get { return this.arrivalDateTime; } set { this.arrivalDateTime = value; } } public DateTime leavingDateTime { get { return this.leavingDateTime; } set { this.leavingDateTime = value; } } public static List<Guest> AllGuests; public Guest() { } public Guest(string name, Room allocatedRoom) { Name = name; rNumber = allocatedRoom.RoomNumber; } public static void CheckIn(string GuestName, Room room, DateTime checkinDateTime, DateTime LeavingDateTime) { Guest newGuest = new Guest(GuestName, room); } } }


)
Reply With Quote
