酒店客房管理系统 要求:
1.客房信息管理:包括客房的编号、类型、价格、状态等信息的录入和修改;
2.顾客信息管理:包括顾客的基本信息、预订信息等的管理;
3.客房预订:客户可以根据需要进行客房的预订,系统会自动判断客房的可用情况;
4.入住管理:客户入住时需要进行登记,同时系统会自动更改客房的状态信息;
*5.结账管理:客户结账需要进行登记,同时系统会自动更改客房的状态信息;
*6.统计报表:包括客房的使用情况、收入情况等的统计报表。5和6 功能可选 使用文件保存信息
类
在这里插入代码片
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#include <string>
// 客房类
class Room {
public:
int number;
std::string type;
double price;
std::string status; // "available", "occupied", "reserved"
Room(int num, std::string t, double p) : number(num), type(t), price(p), status("available") {
}
};
// 顾客类
class Customer {
public:
std::string name;
std::string contact;
int roomNumber;
std::string checkInDate;
std::string checkOutDate;
Customer(std::string n, std::string c, int room, std::string in, std::string out)
: name(n), contact(c), roomNumber(room), checkInDate(in), checkOutDate(out) {
}
};
// 客房信息管理
class RoomManagement {
private:
std::vector<Room> rooms;
std::string roomFilePath = "rooms.txt";
void saveRoomsToFile() {
std::ofstream file(roomFilePath);
for (const auto& room : rooms) {
file << room.number << "," << room.type << "," << room.price << "," << room.status << std::endl;
}
file.close();
}
void loadRoomsFromFile() {
std::ifstream file(roomFilePath);
std::string line;
while (std::getline(file, line)) {
std::istringstream iss(line);
int number;
std::string type;
double price;
std::string status;
std::getline(iss, type, ',');
iss >> number;
iss.ignore();
std::getline(iss, type, ',');
iss >> price;
iss.ignore();
std::getline(iss, status, ',');
rooms.push_back(Room(number, type, price))