-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfor reservation galing kay chatgpt
129 lines (111 loc) · 4.14 KB
/
for reservation galing kay chatgpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
namespace HotelBookingSystem
{
// Define a simple Room class
public class Room
{
public int RoomNumber { get; set; }
public string RoomType { get; set; }
public bool IsOccupied { get; set; }
}
// Define a Reservation class
public class Reservation
{
public int ReservationId { get; set; }
public int RoomNumber { get; set; }
public string GuestName { get; set; }
public DateTime CheckInDate { get; set; }
public DateTime CheckOutDate { get; set; }
}
// Hotel class containing rooms and reservations
public class Hotel
{
private List<Room> rooms;
private List<Reservation> reservations;
public Hotel()
{
rooms = new List<Room>();
reservations = new List<Reservation>();
}
// Method to add a room to the hotel
public void AddRoom(int roomNumber, string roomType)
{
Room room = new Room { RoomNumber = roomNumber, RoomType = roomType, IsOccupied = false };
rooms.Add(room);
}
// Method to display available rooms
public void DisplayAvailableRooms()
{
Console.WriteLine("Available Rooms:");
foreach (Room room in rooms)
{
if (!room.IsOccupied)
{
Console.WriteLine($"Room Number: {room.RoomNumber}, Type: {room.RoomType}");
}
}
}
// Method to make a reservation
public void MakeReservation(int roomNumber, string guestName, DateTime checkInDate, DateTime checkOutDate)
{
Room room = rooms.Find(r => r.RoomNumber == roomNumber);
if (room != null && !room.IsOccupied)
{
room.IsOccupied = true;
Reservation reservation = new Reservation
{
ReservationId = reservations.Count + 1,
RoomNumber = roomNumber,
GuestName = guestName,
CheckInDate = checkInDate,
CheckOutDate = checkOutDate
};
reservations.Add(reservation);
Console.WriteLine("Reservation successful!");
}
else
{
Console.WriteLine("Room is already occupied or doesn't exist.");
}
}
}
class Program
{
static void Main(string[] args)
{
Hotel hotel = new Hotel();
// Adding rooms to the hotel
hotel.AddRoom(101, "Single");
hotel.AddRoom(102, "Double");
hotel.AddRoom(103, "Suite");
bool continueBooking = true;
while (continueBooking)
{
// Display available rooms
hotel.DisplayAvailableRooms();
// Get user input for reservation
Console.WriteLine("\nEnter details for reservation:");
Console.Write("Enter Room Number: ");
int roomNumber = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Guest Name: ");
string guestName = Console.ReadLine();
Console.Write("Enter Check-In Date (YYYY-MM-DD): ");
DateTime checkInDate = Convert.ToDateTime(Console.ReadLine());
Console.Write("Enter Check-Out Date (YYYY-MM-DD): ");
DateTime checkOutDate = Convert.ToDateTime(Console.ReadLine());
// Make a reservation based on user input
hotel.MakeReservation(roomNumber, guestName, checkInDate, checkOutDate);
// Ask if the user wants to continue booking
Console.WriteLine("\nDo you want to make another reservation? (Y/N)");
string response = Console.ReadLine().ToUpper();
if (response != "Y")
{
continueBooking = false;
}
}
Console.WriteLine("\nThank you for using the booking system!");
Console.ReadLine();
}
}
}