This is a hotel reservation system implemented in C++. It consists of a server and multiple clients, which communicate with each other using sockets. The server handles requests from clients and manages the hotel reservation database. Clients can connect to the server and make various requests, such as reserving a room, checking availability, and canceling a reservation.
The server stores the reservation data in .json
files, which can be loaded and saved as needed. The server also ensures that multiple clients can access the system concurrently without conflicts or data corruption.
The clients interact with the system using a command-line interface (CLI), which allows them to enter commands and receive responses from the server. The commands are parsed and validated on the server side to ensure that they are properly formatted and authorized.
There are 5 main folders containing the source and info of this project:
- src folder: This folder contains the source code of the project.
- logs folder: This folder contains the logs of the main server and each client.
- configuration: This folder contains the needed config files.
- bin: This folder contains the object files (.o) produced after compiling src files.
- description: The Persian description of the project.
In the src folder, there are several class entities including:
- HotelManagement: The main processing unit of the program, this class handles the given requests to the server, and gives responses to the clients.
- User: This class contains the data of program users, including ordinary users and admin.
- Room: This class contains room data.
- Reservation: The entity of reservation made by users.
- Date: Contain date data. We use Howard Hinnant date library to handel date operations.
- Logger: This class saves the log of the program into .log files.
- Parser: Used for parsing JSON and string data.
The server IP and port can be modified from the config.json file. The server gets requests in JSON format, parses them and makes a response in JSON again, and sends it to the corresponding client.
Here is the roadmap of how to run and setup server:
- Run server executable:
./server.out
- Set the current date of the program:
>> <Date Time>
Each client can connect to the main server whose config is found in the config.json file. The client gets requests in JSON format, parses them and makes a response in JSON again, and sends it to the main server.
the client file can be run via following command:
./client.out
The client program contains two main menu, the Login, and the Main menu.
There are 3 available command in this menu:
- Sign up:
>> signup <username>
>> <password>
>> <purse>
>> <phone number>
>> <address>
- Sign in:
>> signin <username> <password>
- Exit:
>> exit
Here is the list of available commands:
-
View user information:
-
View all users: This command is only available for admin users.
-
View rooms information:
-
Booking:
book <RoomNum> <NumOfBeds> <CheckInDate> <CheckOutDate>
- Canceling:
canceling <RoomNum> <Number of reservation(per person)>
- Pass Day:
passDay <value>
- Edit Information:
passDay <value>
- Leaving Room:
room <room number>
If you are admin, this command forces people to leave rooms that they are in right now.
If you are a regular customer, you should use this command to leave early.
- Manage Rooms: There are 3 different managing options:
- Add a room:
add <room number> <max capacity> <price>
- Modify a room:
modify <room number> <new max capacity> <new price>
- Delete a room:
remove <room number>
- Log out:
- navigate to project's root directory
- make client and server executables using:
make
- run server executable:
./server.out
- run clients executables:
./client.out