string no;//车牌号
char m_number[20];
char m_kind[20];
char m_name[20];
char m_produceDate[20];//生产日期
double m_weight;
//类别
//名称
//编号
//重量
public:
cars (char *num,char *kind,
char *name,char *date,
double weight)//构造函数
{
strcpy(m_number,num);
strcpy(m_kind,kind);
strcpy(m_name,name);
strcpy(m_produceDate,date);
m_weight=weight;
}
virtual void show()//显示信息
{
cout<<"编号:"<
char *date,double weight,double charge)//构造函数
:cars(num,"taxi",name,date,weight),m_charge(charge)
{
}
};
//组合类
class manage
{
public:
manage();//默认构造函数
void query_car_no();//车牌查询
void query_car_men();//车主查询
void newcar();//新车登记办证
void rework();//二手车过户
void vioRecord();//违规登记
void vio_query(const string no);//违规查询
private:
cars acar;//车辆类对象
violate avio;//违规类对象
carmen acarmen;//车主类对象
};
cars::cars()
{
}
carmen::carmen()
{
}
violate::violate()
{
}
manage::manage()
{
}
//新车登记办证
void manage::newcar()
{
system("cls");
string kind;//车型
string color;
string no;
string name;
string postcard;//身份证
cout << endl << "新车登记办证" << endl << endl;
cout << "请根据提示在下面输入新车信息 : " << endl << endl;
cout << "车主姓名 : ";
cin >> name;
cout << endl << "身份证号 : ";
cin >> postcard;
cout << endl << "
cin >> kind;
cout << endl << "
cin >> color;
cout << endl << " 车牌号 : ";
cin >> no;
车型 : ";
颜色 : ";
ofstream car("d:\\cars.txt", ios::app);
assert(car);
car << setiosflags(ios::left) << setw(20) << postcard << " "
<< no << endl;
car.close();
string username = "car\\"+postcard+".txt";
ofstream carinfo(username.c_str());
carinfo << "车主姓名 : " << name << endl << endl
<< "身份证号 : " << postcard << endl << endl
<< "
<< "
<< " 车牌号 : " << no << endl << endl;
车型 : " << kind << endl << endl
颜色 : " << color << endl << endl
carinfo.close();
cout << endl << "新车信息录入完成!!!" << endl << endl;
system("pause");
}
//
//二手车过户
void manage::rework()
{
system("cls");
string kind;
string color;
string no;
string name;
string postcard;
string no1;
cout << endl << "二手车过户" << endl << endl;
cout << "请输入你想过户的车辆的车牌号 : ";
cin >> no1;
ifstream car("d:\\cars.txt");
if (!car)
{
cout << endl << "这辆车不存在!!!" << endl << endl;
system("pause");
return;
}
bool flag = false;//布尔型
ofstream temp("d:\\temp.txt");
while (car >> postcard >> no)
{
if (no == no1)
{
flag = true;
string carinfo = "car\\"+postcard+".txt";
ifstream car1(carinfo.c_str());
cout << endl << "你想过户的车辆信息如下 : " << endl << endl;
car1>>carinfo;
cout << car1.rdbuf() << endl;
car1.close();
cout << endl << "请在下面输入过户后的车主信息 : " << endl;
cout << endl << "新车主姓名 : ";
cin >> name;
cout << endl << "身份证号码 : ";
cin >> postcard;
ifstream car4(carinfo.c_str());
assert(car4);
string str;
getline(car4, str);
getline(car4, str);
getline(car4, str);
car4 >> str >> str >> kind
>> str >> str >> color
>> str >> str >> no;
car4.close();
carinfo = "car\\"+postcard+".txt";
ofstream car3(carinfo.c_str());
assert(car3);
car3 << "车主姓名 : " << name << endl << endl
<< "身份证号 : " << postcard << endl << endl
<< "
<< "
<< " 车牌号 : " << no << endl << endl;
车型 : " << kind << endl << endl
颜色 : " << color << endl << endl
car3.close();
}
temp << setiosflags(ios::left) << setw(20) << postcard << " "
<< no << endl;
}
temp.close();
car.close();
if (flag)
{
ofstream car2("d:\\cars.txt");
ifstream temp1("d:\\temp.txt");
car2 << temp1.rdbuf() << endl;
cout << endl << "这辆车过户完成!!!" << endl << endl;
}
else
cout << endl << "这辆车不存在!!!" << endl << endl;
system("pause");
}
//违章登记
void manage::vioRecord()
{
system("cls");
string no;
string time;
string place;
cout << endl << "违章登记" << endl << endl;
cout << "请根据提示输入违章车辆相关信息 : " << endl << endl;
cout << "车牌号码 : ";
cin >> no;
cout << endl << "违章时间 : ";
cin >> time;
cout << endl << "违章地点 : ";
cin >> place;
string voiInfo = "D:\\car"+no+".txt";
ofstream voiInfoFile(voiInfo.c_str(), ios::app);
assert(voiInfoFile);
voiInfoFile << setiosflags(ios::left) << setw(30) << time << " "
<< place << endl;
voiInfoFile.close();
cout << endl << "违章登记完成!!!" << endl << endl;
system("pause");
}
//车牌查询
void manage::query_car_no()
{
system("cls");
string findNo;
cout << endl << "根据车牌查询车辆信息" << endl << endl;
cout << "请输入车牌号 : ";
cin >> findNo;
string no;
string postcard;
ifstream car("d:\\cars.txt");
if (!car)
{
cout << endl << "对不起,记录中没有这辆车的相关信息!!!" << endl << endl;
system("pause");
return;
}
bool flag = false;
while (car >> postcard >> no)
{
if (no == findNo)
{
flag = true;
string carInfo = "car\\"+postcard+".txt";
ifstream carInfoFile(carInfo.c_str());
assert(carInfoFile);
cout << endl << "你查询的车辆信息如下 : " << endl << endl;
cout << carInfoFile.rdbuf() << endl;
carInfoFile.close();
vio_query(no);//违章
break;
}
}
car.close();
if (flag)
{
cout << endl << "信息查询完成!!" << endl << endl;
}
else
{
}
cout << endl << "对不起,这个车辆的信息不存在!!!" << endl << endl;
system("pause");
}
//车主查询
void manage::query_car_men()
{
system("cls");
cout << endl << "车主查询" << endl << endl;
cout << "请输入车主的身份证号码 : ";
string postcard1;
cin >> postcard1;
string postcard;
string no;