本系统为一款基于C++开发的汽车租赁管理工具,采用控制台界面简化操作流程。旨在通过高效的数据管理和用户友好的交互方式,提供便捷的汽车租赁服务。适用于小型租赁公司或个人出租车辆的日常运营需求。
一个简单的汽车租赁管理系统(C++控制台程序):利用C++实现对汽车和客户信息的增、删、改等操作,并保存。
以下是部分代码示例:
```cpp
// CarRent.cpp : 定义控制台应用程序的入口点。
#include CarData.h
#include Menu.h
#includeCustomerData.h
int main(){
Menu::welcome(); // 欢迎界面
Menu::login(); // 登录界面
char choice; int carid, customerid;
CustomerData CustomerDB; // 客户数据库
CarData CarDB; // 车辆数据库
Menu::showMenu(); // 显示菜单选项
cout << \t\t\t请选择菜单中的数字以便处理数据:;
cin >> choice;
while (choice != 0) {
switch (choice) {
case 1: // 出租汽车
cout << 出租汽车:\n客户编号:;
cin >> customerid;
try{
if(customerid <= 0)
throw 1;
}catch(...){
cout << 输入有误,请重新输入;
break;
}
cout << 汽车编号:;
cin >> carid;
try {
if (carid <= 0)
throw 1;
} catch (...) {
cout << 输入有误,请重新输入;
break;
}
Customer *r = CustomerDB.search(customerid);
Car *b = CarDB.search(carid);
if(r == NULL)
cout << 不存在该客户! << endl;
else if(b == NULL)
cout << 不存在该汽车! << endl;
else if (b->borrowCar() != 0){
r->borrowCar(b->getNo());
cout << 你在 << asctime(b->getBorTime()) << 成功出租一辆
<< b->getName()
<<每日租金为(不足一天按一天计算):
<< b->getPay();
}
else
cout<< 该汽车已租出!;
break;
case 2: // 归还操作
cout << 归还\n 客户编号:;
cin >> customerid;
try{
if(customerid <= 0)
throw 1;
}catch(...){
cout << 输入有误,请重新输入;
break;
}
Car *b = CarDB.search(carid);
Customer *r = CustomerDB.search(customerid);
if(r == NULL)
cout<< 不存在该客户! << endl;
else if(b == NULL)
cout << 不存在该汽车! << endl;
else if (b->getOnshelf() != 0){
double timeDiff = difftime(b->getTimer1(), b->getTimer());
CarDB.setCostTotal((int)((b->getPay())*((difftime(b->getTimer1(), b->getTimer())) / 86400 + 1)));
cout << 您成功归还一辆
<< b->getName()
<<您的出租时间共计
<< (int)(timeDiff/86400+1)
<< 天
<< endl
<<租金共计
<<(int)((b->getPay())*((difftime(b->getTimer1(), b->getTimer())) / 86400 + 1))
<< 元
<<归还时间为:
<< asctime(b->getRetTime());
b->retCar(); r->retCar(b->getNo());
} else {
cout<< 该汽车已经归还!;
}
break;
case 3: // 汽车管理
CarDB.carData();
break;
case 4: // 客户管理
CustomerDB.customerdata();
break;
case5: // 统计信息
cout << 统计信息: << endl;
cout<< 客户人数为:
<> choice;
}
Menu::thanksForUsing();
return 0;
}
```
上述代码展示了如何通过C++编写一个简单的汽车租赁管理系统,该系统能够处理客户和车辆