由于涉及到多个文件,这里只提供一个大致的框架和部分代码示例。
1. 定义航班类 Flight
```c++
class Flight {
private:
string flightNo; // 航班号
string departure; // 出发地
string destination; // 目的地
string departureTime; // 出发时间
int capacity; // 座位数
int reserved; // 已预订座位数
double price; // 票价
public:
Flight(string no, string dep, string dest, string time, int cap, double p);
void display() const;
bool book(int num);
bool changePrice(double newPrice);
bool changeCapacity(int newCap);
bool cancel(int num);
bool operator==(const Flight& other) const;
friend ostream& operator<<(ostream& os, const Flight& flight);
};
```
2. 定义用户类 User
```c++
class User {
private:
string username; // 用户名
string password; // 密码
vector bookings; // 预订的航班
public:
User(string name, string pwd);
bool login();
bool registerUser();
void displayBookings() const;
bool bookFlight(const vector& flights);
bool changeBooking(const vector& flights);
bool cancelBooking();
bool pay();
friend ostream& operator<<(ostream& os, const User& user);
};
```
3. 定义管理类 Admin
```c++
class Admin {
private:
string username; // 用户名
string password; // 密码
public:
Admin(string name, string pwd);
bool login();
void displayFlights() const;
bool addFlight();
bool deleteFlight();
bool modifyFlight();
friend ostream& operator<<(ostream& os, const Admin& admin);
};
```
4. 定义文件操作类 FileUtil
```c++
class FileUtil {
public:
static vector readFlightsFromFile(string filename);
static bool writeFlightsToFile(const vector& flights, string filename);
static bool writeUsersToFile(const vector& users, string filename);
static