-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathInitial.cpp
More file actions
59 lines (51 loc) · 1.88 KB
/
Initial.cpp
File metadata and controls
59 lines (51 loc) · 1.88 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
namespace HotelBookingSystem
{
public class Room
{
public int RoomNumber { get; set; }
public string Type { get; set; } = string.Empty; // Single, Double, Suite
public decimal PricePerNight { get; set; }
public bool IsAvailable { get; set; } = true;
}
public class Guest
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string PassportNumber { get; set; } = string.Empty;
public string ContactPhone { get; set; } = string.Empty;
}
public class Booking
{
public int BookingId { get; set; }
public int GuestId { get; set; }
public int RoomNumber { get; set; }
public DateTime CheckInDate { get; set; }
public DateTime CheckOutDate { get; set; }
public int NumberOfGuests { get; set; }
public decimal TotalCost => PricePerNight * NightsCount;
public decimal PricePerNight { get; set; }
public int NightsCount => (CheckOutDate - CheckInDate).Days;
}
public class HotelManager
{
private List<Room> _rooms = new();
private List<Guest> _guests = new();
private List<Booking> _bookings = new();
private int _nextGuestId = 1;
private int _nextBookingId = 1;
private const string DataFile = "hotel_data.json";
public HotelManager()
{
LoadData();
if (_rooms.Count == 0)
{
_rooms.Add(new Room { RoomNumber = 101, Type = "Single", PricePerNight = 50 });
_rooms.Add(new Room { RoomNumber = 102, Type = "Double", PricePerNight = 80 });
_rooms.Add(new Room { RoomNumber = 201, Type = "Suite", PricePerNight = 150 });
}
}