By GokiSoft.com| 10:34 12/10/2021|
C Sharp

Chương trình quản lý khách sạn - Develop Hotel Project - Lập Trình C# - Lập Trình C Sharp

Xây dựng menu chương trình như sau

1. Nhập thông tin khách sạn

2. Hiển thị thông tin khách sạn

3. Đặt phong nghỉ

4. Tìm phòng còn trống

5. Thống kê doanh duy khách sạn

6. Tìm kiếm thông tin khách hàng.

7. Thoát chương trình

Yêu cầu :

1. Thiết kế lớp đối tượng khách hàng gồm các thuộc tính (Số CMTND, họ tên, tuổi, giới tính, quê quán)

- Thiết kế get/set cho thuộc tính

- Tạo hàm tạo ko đối và đầy đủ đối số

- Tạo hàm nhập và hiển thị thông tin

2. Thiết kế lớp Hotel gồm các thuộc tính : tên, địa chỉ, loại khách sạn (VIP, Bình dân,...), danh sách các Room, mã khách sạn


- Thiết kế get/set cho thuộc tính

- Tạo hàm tạo ko đối và đầy đủ đối số

- Tạo hàm nhập và hiển thị thông tin

3. Thiết kế lớp Room gồm các thuộc tính : Tên phòng, giá tiền, tầng, số người tối đa ở, mã phòng

- Thiết kế get/set cho thuộc tính

- Tạo hàm tạo ko đối và đầy đủ đối số

- Tạo hàm nhập và hiển thị thông tin

4. Thiết kế lớp Book gồm các thuộc tính : ngày book, ngày trả phòng, Số CMTND người book, mã khách sạn, mã phòng

Chú ý : Số CMTND -> nếu chưa tồn tại -> nhập thông tin KH đó

Mã khách sạn -> Nếu ko tồn tại, yêu cầu nhập đúng khách sạn đã có

Mã Phòng -> yêu cầu nhập đúng mã phòng của KH mà người dùng muốn book -> Nếu nhập sai, yêu cầu nhập đúng mới dừng.

Chú thích menu :

Khi người dùng chọn 1 : Hỏi người dùng số khách sạn cần nhập => Khi nhập mỗi khách sạn thì yêu cầu

- Nhập thông tin khách sạn đó

- Hỏi người dùng nhập số phòng cần nhập cho khách sạn đó => Nhập thông tin từng phòng

Khi người dùng chọn 2 : In toàn bộ thông tin liên quan tới KS

Khi người dùng chọn 3 : Nhập thông tin đặt phòng (Book)

Khi người dùng chọn 4: Nhập vào 1 ngày book và ngày trả phòng, in ra tất cả các phòng có thể đap ứng đc yêu cầu trên

Khi người dùng chọn 5 : In ra tổng tiền mà mỗi khách sạn kiếm được ra màn hình.

Khi người dùng chọn 6 : Nhập Số CMTND khách hàng => In ra tất cả các khách sạn mà khách hàng này đã tới.

Khi người dùng chọn 7 : Thoát chương trình.

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Đỗ Minh Quân [T2008A]
Đỗ Minh Quân

2021-06-02 08:54:12



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HotelManage
{
    class Hotel
    {
        public string No { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public string Type { get; set; }

        public Hotel()
        {

        }
        public Hotel(string No, string Name, string Address, string Type)
        {
            this.No = No;
            this.Name = Name;
            this.Address = Address;
            this.Type = Type;
        }
        public void Input()
        {
            Console.WriteLine("Nhap Ma Khach San:");
            No = Console.ReadLine();
            Console.WriteLine("Nhap Ten Khach San:");
            Name = Console.ReadLine();
            Console.WriteLine("Nhap Dia Chi:");
            Address = Console.ReadLine();
            Console.WriteLine("Nhap Loai Khach San:");
            Type = Console.ReadLine();
            Console.WriteLine("Nhap So Phong Can Them:");
            int N = Convert.ToInt32(Console.ReadLine());

        }
    }
}



##HotelManage



Đỗ Minh Quân [T2008A]
Đỗ Minh Quân

2021-06-02 08:49:22



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace customer
{
    class customer
    {
        public string cmnd { get; set; }
        public string HovaTen { get; set; }
        public int Age { get; set; }
        public string Gender { get; set; }
        public string Address { get; set; }

        public customer()
        {

        }
        public customer(string cmnd, string Fullname, int Age, string Gender, string Address)
        {
            this.cmnd = cmnd;
            this.HovaTen = HovaTen;
            this.Age = Age;
            this.Gender = Gender;
            this.Address = Address;
        }
        public void Input()
        {
            Console.WriteLine("Nhap :");
            cmnd = Console.ReadLine();
            InputWithcmnd();
        }
        public void InputWithcmnd()
        {
            Console.WriteLine("Nhap Ho Ten:");
            HovaTen = Console.ReadLine();
            Console.WriteLine("Nhap Tuoi:");
            Age = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Nhap Gioi Tinh:");
            Gender = Console.ReadLine();
            Console.WriteLine("Nhap Dia Chi:");
            Address = Console.ReadLine();
        }
        public void Display()
        {
            Console.WriteLine("Thong tin Khach Hang: (Ho Ten : {0}, Tuoi : {1},  : {2}, Gioi Tinh : {3}, Dia Chi : {4})", HovaTen, Age, cmnd, Gender, Address);
        }
    } // class

}

## khachhanghotel



Trần Văn Lâm [T2008A]
Trần Văn Lâm

2021-06-02 08:23:25


#Book.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel
{
    class Book
    {
        int CheckIn { get; set; }
        int CheckOut { get; set; }
        public string CMTND { get; set; }
        public string HotelNo { get; set; }
        public string RoomNo { get; set; }

        public Book()
        {

        }
        public Book(int CheckIn, int CheckOut, string CMTND, string HotelNo, string RoomNo)
        {
            this.CheckIn = CheckIn;
            this.CheckOut = CheckOut;
            this.CMTND = CMTND;
            this.HotelNo = HotelNo;
            this.RoomNo = RoomNo;
        }
        public void Input(List<Customer> customerList, List<Hotel> hotelList)
        {
            Console.WriteLine("Nhap CMTND Cua Khach Hang");
            CMTND = Console.ReadLine();
            bool isFind = false;
            for (int i = 0; i < customerList.Count; i++)
            {
                if (customerList[i].CMTND.Equals(CMTND))
                {
                    isFind = true;
                    break;
                }
            }

            if (!isFind)
            {
                Console.WriteLine("Khach Hang Khong Ton Tai! Nhap Moi:");
                Customer customer = new Customer();
                customer.CMTND = CMTND;
                customer.InputWithCMTND();
            }

            DisplayHotelMenu(hotelList);
            Hotel hotel = null;
            while (true)
            {
                HotelNo = Console.ReadLine();
                isFind = false;
                for (int i = 0; i < hotelList.Count; i++)
                {
                    if (hotelList[i].No.Equals(HotelNo))
                    { 
                        isFind = true;
                        hotel = hotelList[i];
                        break;
                    }
                }
                if (!isFind)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Nhap Lai Ma Khach San!");
                }

            }

            DisplayRoomMenu(hotel);
            while (true)
            {
                RoomNo = Console.ReadLine();
                isFind = false;

                for (int i = 0; i < hotel.roomList.Count; i++)
                {
                    if (hotel.roomList[i].No.Equals(RoomNo))
                    {
                        isFind = true;
                        break;
                    }
                }
                if (!isFind)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Nhap Lai Ma Phong Khach San!");
                }
            }
            Console.WriteLine("Nhap Ngay Dat Phong:");
            CheckIn = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Nhap Ngay Tra Phong:");
            CheckOut = Convert.ToInt32(Console.ReadLine());
        }
        public void DisplayHotelMenu(List<Hotel> hotelList)
        {
            for (int i = 0; i < hotelList.Count; i++)
            {
                Console.WriteLine("{0}. - {1} - {2}", i+1, hotelList[i].Name, hotelList[i].No);
                
            }
            Console.WriteLine("Nhap Ma Khach San Can Chon:");
        }
        public void DisplayRoomMenu(Hotel hotel)
        {
            for (int i = 0; i < hotel.roomList.Count; i++)
            {
                Console.WriteLine("{0}. - {1} - {2}", i + 1, hotel.roomList[i].Name, hotel.roomList[i].No) ;

            }
            Console.WriteLine("Nhap Ma Phong Can Chon:");
        }
    }
}


#Customer.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel
{
    class Customer
    {
        public string CMTND { get; set; }
        public string Fullname { get; set; }
        public int Age { get; set; }
        public string Gender { get; set; }
        public string Address { get; set; }

        public Customer()
        {

        }
        public Customer(string CMTND, string Fullname, int Age, string Gender, string Address)
        {
            this.CMTND = CMTND;
            this.Fullname = Fullname;
            this.Age = Age;
            this.Gender = Gender;
            this.Address = Address;
        }
        public void Input()
        {
            Console.WriteLine("Nhap CMTND:");
            CMTND = Console.ReadLine();
            InputWithCMTND();
        }
        public void InputWithCMTND()
        {
            Console.WriteLine("Nhap Ho Ten:");
            Fullname = Console.ReadLine();
            Console.WriteLine("Nhap Tuoi:");
            Age = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Nhap Gioi Tinh:");
            Gender = Console.ReadLine();
            Console.WriteLine("Nhap Dia Chi:");
            Address = Console.ReadLine();
        }
        public void Display()
        {
            Console.WriteLine("Thon tin Khach Hang: (Ho Ten : {0}, Tuoi : {1}, CMTND : {2}, Gioi Tinh : {3}, Dia Chi : {4})", Fullname, Age, CMTND, Gender, Address);
        }
    }
}


#Hotel.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel
{
    class Hotel
    {
        public string No { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public string Type { get; set; }
        public List<Room> roomList = new List<Room>();
        public Hotel()
        {

        }
        public Hotel(string No, string Name, string Address, string Type)
        {
            this.No = No;
            this.Name = Name;
            this.Address = Address;
            this.Type = Type;
        }
        public void Input()
        {
            Console.WriteLine("Nhap Ma Khach San:");
            No = Console.ReadLine();
            Console.WriteLine("Nhap Ten Khach San:");
            Name = Console.ReadLine();
            Console.WriteLine("Nhap Dia Chi:");
            Address = Console.ReadLine();
            Console.WriteLine("Nhap Loai Khach San:");
            Type = Console.ReadLine();
            Console.WriteLine("Nhap So Phong Can Them:");
            int N = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                Room room = new Room();
                room.Input();
                roomList.Add(room);
            }
        }
        public void Display()
        {
            Console.WriteLine("Hotel(Ten Khach San : {0}, Dia Chi : {1}, Loai Khach San : {2})", Name, Address, Type);
            for (int i = 0;i < roomList.Count; i++)
            {
                roomList[i].Display();
            }
        }
        public void DisplayBase()
        {
            Console.WriteLine("Hotel(Ten Khach San : {0}, Dia Chi : {1}, Loai Khach San : {2})", Name, Address, Type);
            
        }
    }
}


#Program.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Customer> customerList = new List<Customer>();
            List<Hotel> hotelList = new List<Hotel>();
            List<Book> bookList = new List<Book>();
            int choose;

            do
            {
                showMenu();
                choose = Convert.ToInt32(Console.ReadLine());

                switch (choose)
                {
                    case 1:
                        Input(hotelList);
                        break;
                    case 2:
                        Display(hotelList);
                        break;
                    case 3:
                        InputBook(hotelList,customerList,bookList);
                        break;
                    case 4:
                        SearchAvailableBook(hotelList, bookList);
                        break;
                    case 5:
                        Statistic(bookList, hotelList);
                        break;
                    case 6:
                        Search(bookList, hotelList);
                        break;
                    case 7:
                        Console.WriteLine("Thoat!!!");
                        break;
                    default :
                        Console.WriteLine("Nhap Lai!!");
                        break;
                }
            } while (choose!=7);
        }

        static void Input(List<Hotel> hotelList)
        {
            Console.WriteLine("Nhap So Khach San Can Them:");
            int N = Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i < N; i++)
            {
                Hotel hotel = new Hotel();
                hotel.Input();

                hotelList.Add(hotel);
            }
        }
        static void Display(List<Hotel> hotelList)
        {
            for (int i = 0; i < hotelList.Count; i++)
            {
                hotelList[i].Display();
            }
        }
        static void InputBook(List<Hotel> hotelList, List<Customer> customerList, List<Book> bookList)
        {
            Book book = new Book();
            book.Input(customerList, hotelList);
            bookList.Add(book);
        }
        static void SearchAvailableBook(List<Hotel> hotelList, List<Book> bookList)
        {
            int checkIn;
            int checkOut;
            Console.WriteLine("Nhap Ngay Dat Phong:");
            checkIn = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Nhap Ngay Tra Phong:");
            checkOut = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < hotelList.Count; i++)
            {
                hotelList[i].DisplayBase();
                Console.WriteLine("Danh Sach Phong Trong:");
                List<Room> rooms = new List<Room>();
                for (int j = 0; j < rooms.Count; j++)
                {
                    if (checkA(bookList, hotelList[i].No, rooms[j], checkIn, checkOut))
                    {
                        rooms[j].Display();
                    }
                }
            }
        }
        static bool checkA(List<Book> bookList, Room room, int checkIn, int checkOut, string roomNo, string hotelNo)
        {
            for (int i = 0; i < bookList.Count; i++)
            {
                Book book = bookList[i];
                if (book.HotelNo.Equals(hotelNo) && book.RoomNo.Equals(roomNo) && (book.CheckIn  >= checkIn && book.CheckIn <= checkOut) || (book.CheckIn >= checkIn && book.CheckOut <= checkOut))
                {
                    return false;
                }
            }
            return true;
        }
        static int Calculate(List<Book> bookList, Hotel hotel )
        {
            int total = 0;
            for (int i = 0; i < bookList.Count; i++)
            {
                if (bookList[i].HotelNo.Equals(hotel.No))
                {
                    int price = GetMoney(hotel.roomList, bookList[i].RoomNo);
                    total += price * (bookList[i].CheckOut) - bookList[i].CheckIn;
                }
            }
            return total;
        }
        static int GetMoney(List<Room> roomList, string roomNo)
        {
            for (int i = 0; i < roomList.Count; i++)
            {
                if (roomList[i].No.Equals(roomNo))
                {
                    return roomList[i].Price;
                }
            }
            return 0;
        }
        static void Statistic(List<Book> bookList, List<Hotel> hotelList)
        {
            for (int i = 0; i < hotelList.Count; i++)
            {
                int total = Calculate(bookList, hotelList[i]);
                Console.WriteLine("{0}. {1} - Doanh Thu : {2}", i + 1, hotelList[i].Name, total);
            }
        }
        static void Search(List<Book> bookList, List<Hotel> hotelList)
        {
            Console.WriteLine("Nhap CMTND Can Tim Kiem:");
            string cmtnd = Console.ReadLine();
            for (int i = 0; i < bookList.Count; i++)
            {
                if (bookList[i].Equals(cmtnd))
                {
                    Hotel hotel = GetHotelByNo(hotelList, bookList[i].HotelNo);
                    if (hotel!=null)
                    {
                        hotel.DisplayBase();
                    }
                }
            }
        }
        static Hotel GetHotelByNo(List<Hotel> hotelList, string hotelNo)
        {
            for (int i = 0; i < hotelList.Count; i++)
            {
                if (hotelList[i].No.Equals(hotelNo))
                {
                    return hotelList[i];
                }
            }
            return null;
        }
        static void showMenu()
        {
            Console.WriteLine("1.Nhap Thong Tin Khach San");
            Console.WriteLine("2.Hien Thi Thong Tin Khach San");
            Console.WriteLine("3.Dat Phong");
            Console.WriteLine("4.Tim Phong Con Trong");
            Console.WriteLine("5.Thong Ke Doanh Thu");
            Console.WriteLine("6.Tim Kiem Thong Tin Khach Hang");
            Console.WriteLine("7.Thoat!!!");
            Console.WriteLine("Lua Chon:");
        }
    }
}


#Room.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel
{
    class Room
    {
        public string Name { get; set; }
        public int Price { get; set; }
        public int Floor { get; set; }
        public int PersonalMax { get; set; }
        public string No { get; set; }

        public Room()
        {

        }
        public Room(string Name, int Price, int Floor, int PersonalMax, string No)
        {
            this.Name = Name;
            this.Price = Price;
            this.Floor = Floor;
            this.PersonalMax = PersonalMax;
            this.No = No;
        }
        public void Input()
        {
            Console.WriteLine("Nhap Ten Phong:");
            Name = Console.ReadLine();
            Console.WriteLine("Nhap Gia:");
            Price = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Nhap So Tang:");
            Floor = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Nhap So Nguoi Toi Da:");
            PersonalMax = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Nhap Ma Phong:");
            No = Console.ReadLine();
        }
        public void Display()
        {
            Console.WriteLine("Room (Ten Phong : {0}, Gia Phong : {1}, So Tang : {2}, So Nguoi Toi Da : {3}, Ma Phong : {4} )", Name, Price, Floor, PersonalMax, No);
        }
    }
}



Nguyễn Hoàng Anh [C1907L]
Nguyễn Hoàng Anh

2020-07-01 04:38:55



using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace HotelManager
{
    class Test
    {
        static void menu()
        {
            Console.WriteLine("1.Enter hotel infomation ");
            Console.WriteLine("2.Show hotel infomation ");
            Console.WriteLine("3.Booking ");
            Console.WriteLine("4.Find empty room ");
            Console.WriteLine("5.Hotel revenue statistics");
            Console.WriteLine("6.Find customer infomation ");
            Console.WriteLine("7.Exit");

        }
        static void HotelInput(List<Hotel> ListHotel)
        {
            Console.WriteLine("How many hotel you want to enter ? :");
            int n = int.Parse(Console.ReadLine());
            bool flag = true;

            for (int i = 0; i < n; i++)
            {

                Console.WriteLine("Enter {0} hotel.", (i + 1));

                Console.WriteLine("Enter hotel number : ");
                string HotelNumber = Console.ReadLine();
                bool flag_side = true;
                for (int j = 0; j < ListHotel.Count; j++)
                {
                    if (HotelNumber == ListHotel[j].HotelNumber)
                    {
                        Console.WriteLine("Hotel is exists!");
                        flag_side = false;
                    }


                }
                if (flag_side == true) {
                    Hotel hotel = new Hotel();
                    hotel.input(HotelNumber);
                    ListHotel.Add(hotel);
                }

            }
        }
        static void HotelDisplay(List<Hotel> ListHotel)
        {
            int ArrayLength = ListHotel.Count;
            for (int i = 0; i < ArrayLength; i++)
            {
                ListHotel[i].display();
            }
        }
        static void Booking(List<Hotel> ListHotel, List<Book> ListBook, List<Customer> ListCustomer)
        {

            Console.WriteLine("Enter booking infomation.");
            Console.WriteLine("Enter hotel number :");
            string HotelNumber = Console.ReadLine();
            int ListHotel_Size = ListHotel.Count;
            string RoomNum = "";
            bool flag = false;

            for (int i = 0; i < ListHotel_Size; i++)
            {
                if (HotelNumber == ListHotel[i].HotelNumber)
                {
                    flag = true;
                }
                if (flag == true)
                {
                    while (true)
                    {
                        Console.WriteLine("Enter room number :");
                        RoomNum = Console.ReadLine();
                        int listRoomSize = ListHotel[i].ListRooms.Count;
                        int j;
                        for (j = 0; j < listRoomSize; j++)
                        {
                            if (RoomNum == ListHotel[i].ListRooms[j].RoomNumber)
                            {
                                break;
                            }
                        }
                        if (j == listRoomSize)
                        {
                            Console.WriteLine("Your room is not exists!");

                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            if (flag == false)
            {
                Console.WriteLine("Your hotel number is not exists!");
            }
            else
            {
                bool flag_1 = true;
                for (int i = 0; i < ListBook.Count; i++)
                {
                    if (RoomNum == ListBook[i].RoomNumber && HotelNumber == ListBook[i].HotelNumber)
                    {
                        Console.WriteLine("Room has been booked!");
                        flag_1 = false;
                    }

                }
                if (flag_1 == true)
                {
                    Console.WriteLine("Enter customer social number :");
                    string SocialNumber = Console.ReadLine();
                    bool flag_2 = true;
                    for (int i = 0; i < ListCustomer.Count; i++)
                    {
                        if (SocialNumber == ListCustomer[i].SocialNumber)
                        {
                            flag_2 = false;
                        }
                    }
                    if (flag_2 == true)
                    {
                        Customer customer = new Customer();
                        customer.input(SocialNumber);
                        ListCustomer.Add(customer);
                    }
                    Console.WriteLine("Enter date booking :");
                    string DateBooking = Console.ReadLine();
                    Console.WriteLine("Enter date leaving : ");
                    string DateLeave = Console.ReadLine();
                    Book book = new Book();
                    book.input(DateBooking, DateLeave, SocialNumber, HotelNumber, RoomNum);
                    BookedRoom bookedRoom = new BookedRoom(DateBooking, DateLeave, SocialNumber, RoomNum);
                    for (int i = 0; i < ListHotel_Size; i++) {
                        if (ListHotel[i].HotelNumber == HotelNumber) {
                            ListHotel[i].ListBookedRooms.Add(bookedRoom);
                        }
                    }
                    ListBook.Add(book);
                }
            }
        }
        static void UnAvailableRoom(List<Hotel> ListHotel) {
            for (int i = 0; i < ListHotel.Count; i++) {
                Console.WriteLine("Hotel {0} ",ListHotel[i].HotelNumber);
                Console.WriteLine("--Booked room : ");
                if (ListHotel[i].ListBookedRooms.Count == 0) {
                    Console.WriteLine("All room is available!");
                }
                for (int j = 0; j < ListHotel[i].ListBookedRooms.Count; j++) {                 
                    ListHotel[i].ListBookedRooms[j].display();
                    for (int k = 0; k < ListHotel[i].ListRooms.Count; k++) {
                        if (ListHotel[i].ListBookedRooms[j].RoomNumber != ListHotel[i].ListRooms[k].RoomNumber) {
                            Console.WriteLine("Room available : {0}",ListHotel[i].ListRooms[k].RoomNumber);
                        }
                    }
                }             
            }
        }
        static void StaticMoney(List<Hotel> ListHotel) {

            for (int i = 0; i < ListHotel.Count; i++) {
                Console.WriteLine("Hotel {0} money static : ", ListHotel[i].HotelNumber);
                float total = 0;
                for (int j = 0; j < ListHotel[i].ListRooms.Count; j++) {
                    for (int k = 0; k < ListHotel[i].ListBookedRooms.Count;k++) {
                        if (ListHotel[i].ListRooms[j].RoomNumber == ListHotel[i].ListBookedRooms[k].RoomNumber) {
                            total += ListHotel[i].ListRooms[j].Price;
                        }
                    }
                }
                Console.Write("{0}\n", total);
            }
        }
        static void FindCustomer(List<Customer> ListCustomer) {
            Console.WriteLine("Enter customer social number : ");
            string SocialNum = Console.ReadLine();
            for (int i = 0; i < ListCustomer.Count; i++) {
                if (SocialNum == ListCustomer[i].SocialNumber) {
                    ListCustomer[i].display();
                }
            }
        }
        static void Main(string[] args)
        {

            List<Hotel> ListHotel = new List<Hotel>();
            List<Book> ListBook = new List<Book>();
            List<Customer> ListCustomer = new List<Customer>();
            while (true)
            {
                menu();
                int choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                    case 1:
                        HotelInput(ListHotel);
                        break;
                    case 2:
                        HotelDisplay(ListHotel);
                        break;
                    case 3:
                        Booking( ListHotel,  ListBook, ListCustomer);
                        for (int i = 0; i < ListBook.Count; i++) {
                            ListBook[i].display();
                        }
                        break;
                    case 4:
                        UnAvailableRoom(ListHotel);
                        break;
                    case 5:
                        StaticMoney(ListHotel);
                        break;
                    case 6:
                        FindCustomer(ListCustomer);
                        break;
                    case 7:
                        return;
                }
            }
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace HotelManager
{
    class BookedRoom
    {
        public string DateBooking { get; set; }
        public string DateLeave { get; set; }
        public string SocialNumberCustomer { get; set; }
        public string RoomNumber { get; set; }

        public BookedRoom(string dateBooking, string dateLeave, string socialNumberCustomer, string roomNumber)
        {
            DateBooking = dateBooking;
            DateLeave = dateLeave;
            SocialNumberCustomer = socialNumberCustomer;
            RoomNumber = roomNumber;
        }

        public BookedRoom()
        {
        }
        public void display() {
            Console.WriteLine("---Date booked : {0} , Date leave : {1} , Customer social number : {2} , Room number : {3}",DateBooking,DateLeave,SocialNumberCustomer,RoomNumber);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace HotelManager
{
    class Book
    {
        public string DateBooking { get; set; }
        public string DateLeave { get; set; }
        public string SocialNumberCustomer { get; set; }
        public string HotelNumber { get; set; }
        public string RoomNumber { get; set; }

        public Book(string dateBooking, string dateLeave, string socialNumberCustomer, string hotelNumber, string roomNumber)
        {
            DateBooking = dateBooking;
            DateLeave = dateLeave;
            SocialNumberCustomer = socialNumberCustomer;
            HotelNumber = hotelNumber;
            RoomNumber = roomNumber;
        }

        public Book()
        {
        }
        public void input(string dateBooking, string dateLeave, string socialNumberCustomer, string hotelNumber, string roomNumber) {
            DateBooking = dateBooking;
            DateLeave = dateLeave;
            SocialNumberCustomer = socialNumberCustomer;
            HotelNumber = hotelNumber;
            RoomNumber = roomNumber;
        }
        public void display()
        {
            Console.WriteLine("Date booking : {0} , Date leaving : {1} , Customer social number : {2} , Hotel number : {3} , Room number : {4}", DateBooking, DateLeave, SocialNumberCustomer, HotelNumber,RoomNumber);

        }
    }
}



using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;

namespace HotelManager
{
    class Room
    {
        public string RoomName { get; set; }
        public float Price { get; set; }
        public int Floor { get; set; }
        public int MaxPeople { get; set; }
        public string RoomNumber { get; set; }
        public string DateBooking { get; set; }
        public string DateLeave { get; set; }
        public Room(string roomName, float price, int floor, int maxPeople, string roomNumber)
        {
            RoomName = roomName;
            Price = price;
            Floor = floor;
            MaxPeople = maxPeople;
            RoomNumber = roomNumber;
        }

        public Room()
        {
        }
        public void input() {

            Console.WriteLine("Room name : ");
            RoomName = Console.ReadLine();
            Console.WriteLine("Price : ");
            Price = float.Parse(Console.ReadLine());
            Console.WriteLine("Floor : ");
            Floor = int.Parse(Console.ReadLine());
            Console.WriteLine("Maximum people : ");
            MaxPeople = int.Parse(Console.ReadLine());
            Console.WriteLine("Room number : ");
            RoomNumber = Console.ReadLine();
        }
        public void display() {
            Console.WriteLine("----Room name : {0} , Price : {1} , Floor : {2} , Maximum people : {3} , Room number : {4}",RoomName,Price,Floor,MaxPeople,RoomNumber);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace HotelManager
{
    class Hotel
    {
        public string HotelNumber { get; set; }
        public string HotelName {get; set;}
        public string Address { get; set; }
        public enum types
        {
            VIP, Normal
        }
        public types HotelType { get; set; }
        public List<Room> ListRooms { get; set; }
        public List<BookedRoom> ListBookedRooms { get; set; }
        public Hotel(string hotelName, string address, types hotelType)
        {
            HotelName = hotelName;
            Address = address;
            HotelType = hotelType;
        }

        public Hotel()
        {
            ListRooms = new List<Room>();
            ListBookedRooms = new List<BookedRoom>();
        }
        public void input(string hotelNumber) {
           
            HotelNumber = hotelNumber;
            Console.WriteLine("Enter hotel name : ");
            HotelName = Console.ReadLine();
            Console.WriteLine("Enter address : ");
            Address = Console.ReadLine();
            Console.WriteLine("Select hotel type : ");
            Console.WriteLine("1.Normal");
            Console.WriteLine("2.VIP");
            int choice = int.Parse(Console.ReadLine());
            if (choice == 2)
            {
                HotelType = types.VIP;

            }
            else 
            {
                HotelType = types.Normal;
            }
            Console.WriteLine("Enter N room : ");
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++) {
                Console.WriteLine("Enter room {0} infomation.", (i + 1));
                Room room = new Room();
                room.input();
                ListRooms.Add(room);
            }
        }

        public void display() {     
            Console.WriteLine("Hotel number : {0} , Hotel name : {1} , Hotel address {2} , Hotel type : {3} ", HotelNumber, HotelName, Address, HotelType);
            int length = ListRooms.Count;
            
            for (int i = 0; i < length; i++)
            {
                ListRooms[i].display();
            }
        }
    }
}



using System;
using System.Security.Cryptography.X509Certificates;

namespace HotelManager
{
    class Customer
    {
        public string SocialNumber { get; set; }
        public string  Name { get; set; }
        public int Age { get; set; }
        public string Gender { get; set; }
        public string HomeTown { get; set; }

        public Customer(string socialNumber, string name, int age, string gender, string homeTown)
        {
            SocialNumber = socialNumber;
            Name = name;
            Age = age;
            Gender = gender;
            HomeTown = homeTown;
        }

        public Customer()
        {
        }
        public void input(string socialNum) {
            
            this.SocialNumber = socialNum;
            Console.WriteLine("Enter name : ");
            this.Name = Console.ReadLine();
            Console.WriteLine("Enter age : ");
            this.Age = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter gender : ");
            this.Gender = Console.ReadLine();
            Console.WriteLine("Enter hometown : ");
            this.HomeTown = Console.ReadLine();
        }
        public void display() {
            Console.WriteLine("Social number : {0} , CustomerName : {1} , Age : {2} , Gender : {3} , HomeTown : {4}", SocialNumber, Name, Age, Gender, HomeTown);
        }
    }
}



trung [C1907L]
trung

2020-06-30 16:46:19



using System;
using System.Globalization;
using System.Collections.Generic;
namespace Qlks
{
    class Program
    {
        static void Main(string[] args)
        {
            int choice = 0;
            do
            {
                Console.WriteLine("Nhap thong tin khach san");
                Console.WriteLine("In toan bo thong tin lien quan toi khach san");
                Console.WriteLine("Nhập thông tin đặt phòng (Book)");
                Console.WriteLine("Nhập vào 1 ngày book và ngày trả phòng, in ra tất cả các phòng có thể đap ứng đc yêu cầu trên");
                Console.WriteLine("In ra tổng tiền mà mỗi khách sạn kiếm được ra màn hình.");
                Console.WriteLine("Nhập Số CMTND khách hàng => In ra tất cả các khách sạn mà khách hàng này đã tới.");
                Console.WriteLine("Thoát chương trình.");
                Console.WriteLine("Your choice : ?");
                choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                    case 1:
                        Console.WriteLine("Input the number of hotel");
                        int n = int.Parse(Console.ReadLine());
                        for (int i = 0; i < n; i++)
                        {
                            Hotel newHotel = new Hotel();
                            newHotel.Input();
                            DataMgr.Instance.ListHotel.Add(newHotel);
                        }
                        break;
                    case 2:
                        Console.WriteLine("All the hotel information are as below:");
                        for (int i = 0; i < DataMgr.Instance.ListHotel.Count; i++)
                        {
                            Console.WriteLine("Information of hotel number {0}", i + 1);
                            DataMgr.Instance.ListHotel[i].Output();
                        }
                        break;
                    case 3:
                        do
                        {
                            Book newBook = new Book();
                            newBook.input();
                            if (!String.IsNullOrEmpty(newBook.RoomCode))
                            {
                                DataMgr.Instance.ListBook.Add(newBook);
                            }
                            Console.WriteLine("Continue (y/n)");
                        } while (Console.ReadLine().Equals("y"));
                        break;
                    case 4:
                        Console.WriteLine("Input book date");
                        string bookDate = Console.ReadLine();
                        Console.WriteLine("Input return date");
                        string returnDate = Console.ReadLine();
                        List<string> resultList = new List<string>();
                        foreach (Book book in DataMgr.Instance.ListBook)
                        {
                            if (book.BookDate.Equals(bookDate) && book.ReturnDate.Equals(returnDate))
                            {
                                if (!resultList.Contains(book.RoomCode))
                                {
                                    resultList.Add(book.RoomCode);
                                }
                            }
                        }
                        foreach (string room in resultList)
                        {
                            Console.WriteLine(room);
                        }
                        break;
                    case 5:
                        int count = DataMgr.Instance.ListHotel.Count;
                        float[] income = new float[count];
                        for (int i = 0; i < income.Length; i++)
                        {
                            income[i] = 0;
                        }
                        foreach (Book book in DataMgr.Instance.ListBook)
                        {
                            //get index of the hotel
                            int i = DataMgr.Instance.ListHotel.FindIndex(x => x.Code.Equals(book.HotelCode));
                            int j = DataMgr.Instance.ListHotel[i].RoomList.FindIndex(y => y.Code.Equals(book.RoomCode));
                            income[i] += DataMgr.Instance.ListHotel[i].RoomList[j].Price;
                        }
                        for (int i = 0 ; i < count; i++)
                        {
                            Console.WriteLine("Hotel {0}, income : {1}",DataMgr.Instance.ListHotel[i],income[i]);
                        }
                        break;
                    case 6:
                        Console.WriteLine("Your social number");
                        string social = Console.ReadLine();
                        List<string> hotelList = new List<string>();
                        foreach (Book book in DataMgr.Instance.ListBook)
                        {
                            if (!hotelList.Contains(book.HotelCode))
                            {
                                hotelList.Add(book.HotelCode);
                            }
                        }
                        foreach (string hotel in hotelList)
                        {
                            Console.WriteLine(hotel);
                        }
                        break;
                    case 7:
                        Console.WriteLine("Bye bye ...");
                        break;
                    default:
                        Console.WriteLine("Invalid input");
                        break;
                }
            }
            while (choice != 7);
        }
    }
}



using System;

namespace Qlks
{
    public class Customer
    {
        public Customer(string socialNumber, string name, int age, string gender, string homeTown)
        {
            SocialNumber = socialNumber;
            Name = name;
            Age = age;
            Gender = gender;
            HomeTown = homeTown;
        }

        public Customer()
        {
        }

        public string SocialNumber { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
        public string Gender { get; set; }
        public string HomeTown { get; set; }

        public void Input()
        {
            Console.WriteLine("Please input social number");
            this.SocialNumber = Console.ReadLine();
            Console.WriteLine("Please input name");
            this.Name = Console.ReadLine();
            Console.WriteLine("Please input age");
            this.Age = int.Parse(Console.ReadLine());
            Console.WriteLine("Please input gender");
            this.Gender = Console.ReadLine();
            Console.WriteLine("Please input home town");
            this.HomeTown = Console.ReadLine();
        }

        public void Output()
        {
            Console.WriteLine("Social number is : {0}",SocialNumber);
            Console.WriteLine("Name is : {0}", Name);
            Console.WriteLine("Gender is : {0}", Gender);
            Console.WriteLine("Age is : {0}", Age);
            Console.WriteLine("Home town is : {0}", HomeTown);
        }
    }
}



using System;
using System.Collections.Generic;
namespace Qlks
{
    public enum Category
    {
        VIP,
        BinhDan
    }
    public class Hotel
    {
        //tên, địa chỉ, loại khách sạn(VIP, Bình dân,...),
        public string Name { get; set; }
        public string Address { get; set; }
        public Category HotelType { get; set; }
        public List<Room> RoomList { get; set; }
        public string Code;

        public Hotel(string name, string address, Category hotelType, string code)
        {
            Name = name;
            Address = address;
            HotelType = hotelType;
            this.RoomList = new List<Room>();
            Code = code;
        }

        public Hotel()
        {
            RoomList = new List<Room>();
        }

        public void Input()
        {
            Console.WriteLine("Input name");
            Name = Console.ReadLine();
            Console.WriteLine("Input address");
            Address = Console.ReadLine();
            Console.WriteLine("Hotel type: \n 1.VIP \n2.Binh dan.\n Your choice : ...");
            switch (int.Parse(Console.ReadLine()))
            {
                case 1:
                    HotelType = Category.VIP;
                    break;
                default:
                    HotelType = Category.BinhDan;
                    break;
            }
            while (true)
            {
                Room nRoom = new Room();
                nRoom.Input();
                RoomList.Add(nRoom);
                Console.WriteLine("Continue ? (y/n)");
                if (Console.ReadLine().Equals("n"))
                {
                    break;
                }
            }
            Console.WriteLine("Input hotel code");
            Code = Console.ReadLine();
        }

        public void Output()
        {
            Console.WriteLine("Name : {0}",Name);
            Console.WriteLine("Address : {0}",Address);
            Console.WriteLine("Hotel type : {0}",HotelType);
            Console.WriteLine("Room list : ");
            foreach (Room room in RoomList)
            {
                room.Output();
            }
            Console.WriteLine("Hotel code: {0}",Code);
            Console.WriteLine("--------------");
        }
    }
}



using System;
using System.Collections.Generic;
namespace Qlks
{
    public class DataMgr
    {
        private static DataMgr instance = null;
        private static List<Hotel> _listHotel; 
        public List<Hotel> ListHotel {
            get {
                if (_listHotel == null)
                {
                    _listHotel = new List<Hotel>();
                }
                return _listHotel;
            }
            private set{}
        }
        
        private static List<Customer> _listCustomer;
        public List<Customer> ListCustomer {
            get {
                if (_listCustomer == null)
                {
                    _listCustomer = new List<Customer>();
                }
                return _listCustomer;
            }
            private set{}
        }

        private static List<Book> _listBook;
        public List<Book> ListBook {
            get {
                if (_listBook == null)
                {
                    _listBook = new List<Book>();
                }
                return _listBook;
            }
            private set{}
        }
        private DataMgr(){}

        public static DataMgr Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new DataMgr();
                }
                return instance;
            }
            private set{}
        }
    }
}



using System;
using System.Collections.Generic;

namespace Qlks
{
    public class Book
    {
        // ngày book, ngày trả phòng, Số CMTND người book, mã khách sạn, mã phòng
        public string BookDate { get; set; }
        public string ReturnDate { get; set; }
        public string SocialNumber { get; set; }
        public string HotelCode { get; set; }
        public string RoomCode { get; set; }

        public Book() { }

        public void input()
        {
            Console.WriteLine("Input book date");
            string bookDate = Console.ReadLine();
            Console.WriteLine("Input return date");
            string returnDate = Console.ReadLine();
            Console.WriteLine("Input social number");
            string social = Console.ReadLine();
            Console.WriteLine("Input hotel code");
            string hotelCode = Console.ReadLine();
            Console.WriteLine("Input room code");
            string roomCode = Console.ReadLine();
            //check social number
            int i;
            for (i = 0; i < DataMgr.Instance.ListCustomer.Count; i++)
            {
                if (DataMgr.Instance.ListCustomer[i].SocialNumber.Equals(social)) break;
            }
            if (i == DataMgr.Instance.ListCustomer.Count)
            {
                Console.WriteLine("Customer not found ... Input the new customer ?");
                if (Console.ReadLine().Equals("y"))
                {
                    //input new customer
                    Customer cst = new Customer();
                    cst.Input();
                    DataMgr.Instance.ListCustomer.Add(cst);
                    social = cst.SocialNumber;
                }
                else
                {
                    return;
                }
            }
            for (i = 0; i < DataMgr.Instance.ListHotel.Count; i++)
            {
                if (DataMgr.Instance.ListHotel[i].Code.Equals(hotelCode)) break;
            }
            if (i == DataMgr.Instance.ListHotel.Count)
            {
                Console.WriteLine("Hotel not found...");
                return;
            }
            Hotel hotel = DataMgr.Instance.ListHotel[i];
            for (i = 0; i < hotel.RoomList.Count; i++)
            {
                if (hotel.RoomList[i].Code.Equals(roomCode)) break;
            }
            if (i == hotel.RoomList.Count)
            {
                Console.WriteLine("Room not found");
                return;
            }
            BookDate = bookDate;
            ReturnDate = returnDate;
            SocialNumber = social;
            HotelCode = hotelCode;
            RoomCode = roomCode;
        }
    }
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Qlks
{
    public class Room
    {
        

        public Room()
        {

        }

        public Room(string name, float price, int floor, int maxSlot, string code)
        {
            Name = name;
            Price = price;
            Floor = floor;
            MaxSlot = maxSlot;
            Code = code;
        }

        //Tên phòng, giá tiền, tầng, số người tối đa ở, mã phòng

        public string Name { get; set; }
        public float Price { get; set; }
        public int Floor { get; set; }
        public int MaxSlot { get; set; }
        public string Code { get; set; }

        public void Input()
        {
            Console.WriteLine("Please input name");
            this.Name= Console.ReadLine();
            Console.WriteLine("Please input price");
            this.Price= float.Parse(Console.ReadLine());
            Console.WriteLine("Please input floor");
            this.Floor= int.Parse(Console.ReadLine());
            Console.WriteLine("Please input max slot");
            this.MaxSlot = int.Parse(Console.ReadLine());
            Console.WriteLine("Please input code");
            this.Code = Console.ReadLine();
        }

        public void Output()
        {
            Console.WriteLine("Name is : {0}", Name);
            Console.WriteLine("Price is : {0}", Price);
            Console.WriteLine("Floor is : {0}", Floor);
            Console.WriteLine("Max slot is : {0}", MaxSlot);
            Console.WriteLine("Code is : {0}", Code);
        }
    }
}



Ngô Quang Huy [C1907L]
Ngô Quang Huy

2020-06-29 14:12:12



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newBT
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Hotel> listHotel = new List<Hotel>();
            List<Customer> listCustomer = new List<Customer>();
            List<Book> listBook = new List<Book>();
            while (true)
            {
                showMenu();
                int choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Hotel hotel = new Hotel();
                        hotel.input();
                        listHotel.Add(hotel);
                        break;
                    case 2:
                        Console.WriteLine("Insert hotelCode: ");
                        string hotelCode = Console.ReadLine();
                        foreach (Hotel hot in listHotel)
                        {
                            if (hotelCode.Equals(hot.hotelcode))
                            {
                                hot.output();
                            }
                        }
                        break;
                    case 3:
                        Book book = new Book();
                        book.input();
                        listBook.Add(book);
                        break;
                    case 4:
                        break;
                    case 5:
                        int total = 0;
                        Console.WriteLine("Insert hotelCode: ");
                        string searchHotel = Console.ReadLine();
                        foreach (Hotel hote in listHotel)
                        {
                            if (searchHotel.Equals(hote.hotelcode))
                            {
                                foreach (room Room in hote.ListRoom)
                                {
                                    total = total + Room.price;
                                }
                            }
                        }
                        Console.WriteLine("Total Money: "+ total);
                        break;
                    case 6:
                        Console.WriteLine("Insert CMND: ");
                        string searchCMND = Console.ReadLine();
                        foreach (Book bok in listBook)
                        {
                            if (searchCMND.Equals(bok.CMND))
                            {
                                foreach(Hotel hote in listHotel)
                                {
                                }
                            }
                        }
                        break;
                    case 7:
                        Environment.Exit(0);
                        break;
                }
            }
        }

        static void showMenu()
        {
            Console.WriteLine("1. Insert A Hotel");
            Console.WriteLine("2. Display A Hotel");
            Console.WriteLine("3. Book A Room");
            Console.WriteLine("4. Find Booked Room by Date");
            Console.WriteLine("5. Display Total Money");
            Console.WriteLine("6. Display all Hotel from CMND");
            Console.WriteLine("7. Exit");
            Console.WriteLine("Choose: ");
        }
    }
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newBT
{
    class Customer
    {
        public string CMND { get; set; }
        public string name { get; set; }
        public int age { get; set; }
        public string gender { get; set; }
        public string country { get; set; }



        public Customer()
        {

        }

        public Customer(string CMND, string name, int age, string gender, string country)
        {
            this.CMND = CMND;
            this.name = name;
            this.age = age;
            this.gender = gender;
            this.country = country;
        }

        public void input()
        {
            Console.WriteLine("Insert CMND: ");
            CMND = Console.ReadLine();
            Console.WriteLine("Insert name: ");
            name = Console.ReadLine();
            Console.WriteLine("Insert age: ");
            age = int.Parse(Console.ReadLine());
            Console.WriteLine("Insert gender: ");
            gender = Console.ReadLine();
            Console.WriteLine("Insert country: ");
            country = Console.ReadLine();
        }
        
        public void output()
        {
            Console.WriteLine("CMND: " + CMND + "; " + "name: " + name + "; " + "age: " + age + "; " + "gender: " + gender + "; " + "country: " + country);
        }

    }
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newBT
{
    class Hotel
    {
        public string name { get; set; }
        public string address { get; set; }
        public string type { get; set; }
        public string hotelcode { get; set; }

        public List<room> ListRoom { get; set; }

        public Hotel()
        {
            ListRoom = new List<room>();
        }

        public Hotel(string name, string address, string type, string hotelcode, List<room> listRoom)
        {
            this.name = name;
            this.address = address;
            this.type = type;
            this.hotelcode = hotelcode;
            this.ListRoom = listRoom;
        }

        public void input()
        {
            Console.WriteLine("Insert name: ");
            name = Console.ReadLine();
            Console.WriteLine("Insert address: ");
            address = Console.ReadLine();
            Console.WriteLine("Insert type: ");
            type = Console.ReadLine();
            Console.WriteLine("Insert hotelcode: ");
            hotelcode = Console.ReadLine();
            Console.WriteLine("Insert number of room: ");
            int numb = int.Parse(Console.ReadLine());
            for (int i = 0; i < numb; i++)
            {
                room Room = new room();
                Room.input();
                listRoom.Add(Room);
            }
        }

        public void output()
        {
            Console.WriteLine("name: " + name + "; " + "address: " + address + "; " + "type: " + type + "; " + "hotelcode: " + hotelcode);
            foreach(room a in listRoom){
                a.output();
            }
        }
    }
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newBT
{
    class room
    {
        public string name { get; set; }
        public int price { get; set; }
        public int floor { get; set; }
        public int maximum { get; set; }
        public string roomcode { get; set; }

        public room()
        {

        }

        public room(string name, int price, int floor, int maximum, string roomcode)
        {
            this.name = name;
            this.price = price;
            this.floor = floor;
            this.maximum = maximum;
            this.roomcode = roomcode;
        }

        public void input()
        {
            Console.WriteLine("Insert name: ");
            name = Console.ReadLine();
            Console.WriteLine("Insert price: ");
            price = int.Parse(Console.ReadLine());
            Console.WriteLine("Insert floor: ");
            price = int.Parse(Console.ReadLine());
            Console.WriteLine("Insert maximum: ");
            maximum = int.Parse(Console.ReadLine());
            Console.WriteLine("Insert roomcode: ");
            roomcode = Console.ReadLine();
        }

        public void output()
        {
            Console.WriteLine("name: " + name + "; " + "price: " + price + "; " + "floor: " + floor + "; " + "maximum: " + maximum + "; " + "roomcode: " + roomcode);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newBT
{
    class Book
    {
        public string bookDate { get; set; }
        public string bookReturn { get; set; }
        public string CMND { get; set; }
        public string hotelCode { get; set; }
        public string roomCode { get; set; }

        public Book()
        {

        }

        public Book(string bookDate, string bookReturn, string cMND, string hotelCode, string roomCode)
        {
            this.bookDate = bookDate;
            this.bookReturn = bookReturn;
            this.CMND = cMND;
            this.hotelCode = hotelCode;
            this.roomCode = roomCode;
        }

        public void input()
        {
            Console.WriteLine("Insert bookDate: ");
            bookDate = Console.ReadLine();
            Console.WriteLine("Insert bookReturn: ");
            bookReturn = Console.ReadLine();
        }

        public void output()
        {
            Console.WriteLine("bookDate: " + bookDate + "; " + "bookReturn: " + bookReturn + "; " + "CMND: " + CMND + "; " + "hotelCode: " + hotelCode + "; " + "roomCode: " + roomCode);
        }
    }
}



Trương Công Vinh [T1907A]
Trương Công Vinh

2020-05-25 18:20:05



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Customer
    {
        public string cmnd { get; set; }
        public string name { get; set; }
        public string gender { get; set; }
        public string address { get; set; }
        public int age { get; set; }
        public Customer()
        {

        }
        public Customer(string cmnd , string name, int age, string gender,string address )
        {
            this.address = address;
            this.age = age;
            this.cmnd = cmnd;
            this.gender = gender;
            this.name = name;
        }
        public void input()
        {
            Console.WriteLine("CMND : ");
            cmnd = Console.ReadLine();
            input(cmnd);
        }
        public void input(string cmnd)
        {
            this.cmnd = cmnd;
            Console.WriteLine("Name : ");
            name = Console.ReadLine();
            Console.WriteLine("Age : ");
            age = int.Parse(Console.ReadLine());
            Console.WriteLine("Gender : ");
            gender = Console.ReadLine();
            Console.WriteLine("Address : ");
            address = Console.ReadLine();
        }

        public void display()
        {
            Console.WriteLine("CMND : {0} , Fullname : {1} , Age : {2} , Gender : {3} , Address : {4}",cmnd,name,age,gender,address);
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Hotel
    {

        public string name { get; set; }
        public string address { get; set; }
        public string Rank { get; set; }

        public List<Room> rooms { get; set; }

        public string hotelID { get; set; }
        public Hotel()
        {
            rooms = new List<Room>();
        }
        public void input()
        {
            
            Console.WriteLine("Code of hotel : ");
            hotelID = Console.ReadLine();
            input(hotelID);
        }
        public void input(string hotelID)
        {
            Console.WriteLine("Name of hotel : ");
            name = Console.ReadLine();
            Console.WriteLine("Address of hotel : ");
            address = Console.ReadLine();
            rankHotel();
            

            inputRoom(rooms);
            this.hotelID = hotelID;

        }
        public void display()
        {
            Console.WriteLine("hotelName : {0} , Address : {1} , Level : {2} , hotelID : {3} ", name, address, Rank, hotelID);
            Console.WriteLine("List of Room  : ");
            foreach (var item in rooms)
            {
                item.display();
            }
            Console.WriteLine("------------------------------------------------------------");

        }

        private void inputRoom(List<Room> rooms)
        {
            Console.WriteLine("Seting Room's Information : ");
            for (; ; )
            {
                Room room = new Room();
                room.input();
                rooms.Add(room);
                Console.WriteLine("add room : (y/n)");
                string option = Console.ReadLine();
                if (option.Equals("n"))
                {
                    break;
                }
            }
        }

        private void rankHotel()
        {
            bool dk = true;
            while (dk)
            {
                Console.WriteLine("1.VIP");
                Console.WriteLine("2.Normal");
                Console.WriteLine("Choose : ");
                int choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Rank = "VIP";
                        dk = false;
                        break;
                    case 2:
                        Rank = "Normal";
                        dk = false;
                        break;
                    default:
                        Console.WriteLine("Error !! ");

                        break;

                }
            }
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Room
    {
        public string roomName { get; set; }
        public int floorNumber { get; set; }
        public int maxPerson { get; set; }
        public int price { get; set; }
        public string roomCode { get; set; }

        public Room()
        {

        }
        public Room(string roomName , int floorNumber ,int maxPerson , int price ,string roomCode)
        {
            this.floorNumber = floorNumber;
            this.maxPerson = maxPerson;
            this.price = price;
            this.roomCode = roomCode;
            this.roomName = roomName;
        }
        public void input()
        {
            Console.WriteLine("ten phong : ");
            roomName = Console.ReadLine();
            Console.WriteLine("tang  : ");
            floorNumber = int.Parse(Console.ReadLine());
            Console.WriteLine("so nguoi toi da : ");
            maxPerson = int.Parse(Console.ReadLine());
            Console.WriteLine("gia phong 1 ngay : ");
            price = int.Parse(Console.ReadLine());
            Console.WriteLine("ma phong : ");
            roomCode = Console.ReadLine();
        }
        public void display()
        {
            Console.WriteLine("roomName : {0} , numberFloor : {1} , maxPerson : {2} , Price : {3} , roomCode : {4}",roomName,floorNumber,maxPerson,price,roomCode);
            
        }
    }
}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class Book
    {
        public DateTime checkin { get; set; }
        public DateTime checkout { get; set; }
        public string cmnd { get; set; } 

        public string hotelID { get; set; }

        public string roomCode { get; set; }


        public Book()
        {
            
        }
        public void display()
        {
            Console.WriteLine("CheckIn : {0} , CheckOut : {1} , Cmnd : {2} , HotelID : {3} , roomID : {4}",checkin,checkout,cmnd,roomCode);
        }
        public void input(List<Hotel> hotels,List<Customer> customers)
        {
            Console.WriteLine("Ngay book (dd/mm/YYYY): ");
            string strDatetime = Console.ReadLine();
            checkin = DateTime.ParseExact(strDatetime,"dd/MM/yyyy",null);
            Console.WriteLine("Ngay tra phong (dd/mm/YYYY): ");
            strDatetime = Console.ReadLine();
            checkout = DateTime.ParseExact(strDatetime,"dd/MM/yyyy",null);
            inputCMND(customers);
            inputHotelID(hotels);
        }
        private void inputCMND(List<Customer> customers)
        {
            bool dk = false;
            Console.WriteLine("Enter CMND : ");
            string find = Console.ReadLine();
            foreach (var item in customers)
            {
                if (find.Equals(item.cmnd))
                {
                    cmnd = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin Customer");
                Customer customer = new Customer();
                customer.input(find);
                customers.Add(customer);
                cmnd = customer.cmnd;
            }

        }
        private void inputHotelID(List<Hotel> hotels)
        {
            bool dk = false;
            Console.WriteLine("Enter hotelID : ");
            string find = Console.ReadLine();
            foreach (var item in hotels)
            {
                if (find.Equals(item.hotelID))
                {
                    hotelID = find;
                    dk = true;
                    break;
                }
            }
            if (!dk)
            {
                Console.WriteLine("nhập thông tin hotel : ");
                Hotel hotel = new Hotel();
                hotel.input();
                hotelID = hotel.hotelID;
                hotels.Add(hotel);
            }
            foreach (var item in hotels)
            {
                if (hotelID.Equals(item.hotelID))
                {
                    findRoom(item);
                }
            }


        }

        private void findRoom(Hotel hotel)
        {
            bool dk = true;
            while (dk)
            {
                foreach (Room item in hotel.rooms)
                {
                    item.display();
                }
                Console.WriteLine("Enter roomCode to book : ");
                string check;
                check = Console.ReadLine();
                foreach (Room item in hotel.rooms)
                {
                    if (check.Equals(item.roomCode))
                    {
                        roomCode = check;
                        dk = false;
                        break;
                    }
                }
                if (dk)
                {
                    Console.WriteLine("ma phong sai !!");
                }
            }
        }
        

    }

}



using System;
using System.Collections.Generic;
using System.Text;

namespace Hotel
{
    class FunctionMenu
    {
        public FunctionMenu()
        {

        }
        public void findCustomer(List<Customer> customers)
        {
            Console.WriteLine("Enter CMND of Customer to find : ");
            string find = Console.ReadLine();
            bool isFind = false;
            foreach (Customer customer in customers)
            {
                if (find.Equals(customer.cmnd))
                {
                    customer.display();
                    isFind = true;
                    break;
                }
            }
            if (!isFind)
            {
                Console.WriteLine("Not found Customer !!!");
            }

        }
        public void totalIncome(List<Book> books, List<Hotel> hotels)
        {
            

            foreach (var hotel in hotels)
            {
                int income = 0;
                foreach (Room room in hotel.rooms)
                {
                    foreach (Book book in books)
                    {
                        if (room.roomCode.Equals(book.roomCode))
                        {
                            TimeSpan Time = book.checkout - book.checkin;
                            int TongSoNgay = Time.Days;
                            income += (room.price*TongSoNgay);
                            break;
                        }
                    }

                }
                Console.WriteLine("Thu nhap cua KS: {0} la : ${1} .",hotel.name,income);
            }

        }

        public void inputHotel(List<Hotel> hotels)
        {
            for (; ; )
            {
                Hotel hotel = new Hotel();
                hotel.input();
                hotels.Add(hotel);
                Console.WriteLine("add new hotel : ( y/ n )");
                string option = Console.ReadLine();
                if (option.Equals("n"))
                {
                    break;
                }
            }
        }
        public void displayHotel(List<Hotel> hotels)
        {
            foreach (var item in hotels)
            {
                item.display();
            }

        }
        public void booking(List<Book> books, List<Hotel> hotels, List<Customer> customers)
        {
            Book book = new Book();
            book.input(hotels,customers);
            books.Add(book);
        }
        public void findRoomByDate(List<Book> books, List<Hotel> hotels)
        {
            if (hotels.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }

            Hotel currentHotel = null;
            for (; ; )
            {
                foreach (Hotel hotel in hotels)
                {
                    Console.WriteLine("Ma KS: {0}, Ten KS: {1}", hotel.hotelID, hotel.name);
                }
                Console.WriteLine("Enter hotelID : ");
                string hotelID = Console.ReadLine();
                foreach (Hotel hotel in hotels)
                {
                    if (hotel.hotelID.Equals(hotelID))
                    {
                        currentHotel = hotel;
                        break;
                    }
                }
                if (currentHotel != null)
                {
                    break;
                }
                Console.WriteLine("(Not Found) Nhap lai: ");
            }
            if (currentHotel.rooms.Count == 0)
            {
                Console.WriteLine("khong co data!!!");
                return;
            }

            Console.WriteLine("Ngay CheckIn (dd/mm/YYYY): ");
            string dateTime = Console.ReadLine();
            DateTime CheckIn = DateTime.ParseExact(dateTime, "dd/MM/yyyy", null);

            Console.WriteLine("Ngay CheckOut (dd/mm/YYYY): ");
            dateTime = Console.ReadLine();
            DateTime CheckOut = DateTime.ParseExact(dateTime, "dd/MM/yyyy", null);

            
            foreach (var room in currentHotel.rooms)
            {
                List<Book> currentBooking = new List<Book>();
                
                foreach (var book in books)
                {

                    if (book.hotelID.Equals(currentHotel.hotelID)&&book.roomCode.Equals(room.roomCode))
                    {
                        currentBooking.Add(book);
                    }
                   

                }
                bool isFind = false;
                foreach (var book in currentBooking)
                {
                    if (DateTime.Compare(book.checkin, CheckOut) > 0 || DateTime.Compare(book.checkout, CheckIn) < 0)
                    {
                        //room dat yeu cau
                    }
                    else
                    {
                        isFind = true;
                        break;
                    }

                }
                if (!isFind)
                {
                    Console.WriteLine("Room No: {0}, Room Name: {1}", room.roomCode, room.roomName);
                }

            }
           
        }





    }
}



using System;
using System.Collections.Generic;
using System.Text;
namespace Hotel
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8; 
            FunctionMenu functionMenu = new FunctionMenu();
            List<Book> books = new List<Book>();
            List<Room> rooms = new List<Room>();
            List<Hotel> hotels = new List<Hotel>();
            List<Customer> customers = new List<Customer>();
            Console.WriteLine("Hello World!");
            int c;
            do
            {
                menu();
                c = int.Parse(Console.ReadLine());
                switch (c)
                {
                    case 1:
                        functionMenu.inputHotel(hotels);
                        break;
                    case 2:
                        functionMenu.displayHotel(hotels);
                        break;
                    case 3:
                        functionMenu.booking(books,hotels,customers);
                        break;
                    case 4:
                        functionMenu.findRoomByDate(books,hotels);
                        break;
                    case 5:
                        functionMenu.totalIncome(books,hotels);
                        break;
                    case 6:
                        functionMenu.findCustomer(customers);
                        break;
                    case 7:
                        Console.WriteLine("Thoat !!");
                        break;
                    default:
                        Console.WriteLine("Nhap sai !!");
                        break;


                }

            } while (c!=7);

        }
        static void menu()
        {
            Console.WriteLine("  1. Nhập thông tin khách sạn    ");
            Console.WriteLine("  2. Hiển thị thông tin khách sạn   ");
            Console.WriteLine("  3. Đặt phong nghỉ   ");
            Console.WriteLine("  4. Tìm phòng còn trống   ");
            Console.WriteLine("  5. Thống kê doanh duy khách sạn   ");
            Console.WriteLine("  6. Tìm kiếm thông tin khách hàng.   ");
            Console.WriteLine("  7. Thoát chương trình   ");
            Console.WriteLine(" chon :   ");
        }
    }
}