停车场管理系统报告

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

信息科学与技术学院本科一年级








专业:物联网
班级:一班
开发小组成员姓名:杨宗霖,叶少晖,娄旸
开发小组成员学号:********,********,********
实习单位:软件工程实验中心
2013 年7 月27
目录
诚信承诺书 ................................................................................................................................. - 3 -
一、系统题目.............................................................................................................................. - 4 -
二、项目分工.............................................................................................................................. - 4 -
三、系统需求分析...................................................................................................................... - 4 -
1.系统设计的目的与意义.................................................................................................. - 5 -
2.系统功能需求、系统主要功能图.................................................................................. - 5 -
四、总体设计.............................................................................................................................. - 5 -
1.系统功能分析;.............................................................................................................. - 5 -
2.类的描述;...................................................................................................................... - 6 -
3.各功能菜单介绍;.......................................................................................................... - 6 -
4.系统功能模块的划分与设计,各功能函数的说明;.................................................. - 6 -
五、详细设计与实现.................................................................................................................. - 6 -
1.各个类设计、实现与详细说明;.................................................................................. - 6 -
2.各函数的设计与实现(含流程图)与详细说明;...................................................... - 9 -
3.数据的保存和装载........................................................................................................ - 46 -
六、运行结果............................................................................................................................ - 47 -
1、初始化设置.................................................................................................................. - 47 -
2、使用系统(以最后一种设置为本操作演示的基础).............................................. - 52 -
七、程序清单............................................................................................................................ - 55 -
1.源文件的实现................................................................................................................. - 55 -
八、主要知识点........................................................................................................................ - 97 -
九、软件开发实习收获、体会与建议.................................................................................... - 98 -
1.软件开发实习收获与体会;......................................................................................... - 98 -
2.对软件开发实习的建议和意见..................................................................................... - 98 -
诚信承诺书
本小组成员_____________________________保证本次软件开发实习报告为自己独立总结、写作完成,报告内容和源程序不会有三分之一以上的内容与其他同学雷同,如果出现以上情况,本次软件开发实习成绩自愿记为零分。

承诺人签名:____________________________________
日期:_______年______月_____日
一、系统题目
停车场管理系统
二、项目分工
写明小组成员具体分工,可以用表格表示,可具体到每人承担的类设计、函数设计、所
三、系统需求分析
1.系统设计的目的与意义
本系统是一个综合的停车场管理系统,设计本系统的目的是使本系统能满足众多的停车场对于其业务的管理。

即本停车场管理系统不是建立在一个具体存在的停车场的基础上来设计的,我们设计的是一个适用于绝大多数停车场的管理系统,这样以来,我们的程序生存空间就会大大增大。

对于不同的停车场,经营者可以根据他的停车场的具体情况来进行系统设置,一旦设置成功,并保存在初始化文件里面后,该停车场管理系统就是为他这一个停车场服务的。

我们在满足不同用户需求的同时又做到了每个用户的个性化,体现了他们需要的独特性。

意义在于我们只要设计一个程序,用户购买我们的程序,用户进行初始化设置并保存后就可以作为一个专门供他的停车场服务的管理程序。

即我们可以减少程序的修改,用较为功能强大的程序去满足各种客户的需求。

程序的可移植性很好,突出表现在它的适应性好,可以满足不同的需求。

2.系统功能需求、系统主要功能图
1)用户可以自己设置他的停车场的特点,包括车位个数,有没有区分忙闲时,有没有区分
车型,收费制度;
2)用户可以用菜单进入各级子菜单,各级子菜单也可以返回上一级菜单;
3)用户可以对进入停车场的车辆信息进行登记;
4)用户可以把登记的信息存入文件里,下次打开的时候车辆信息还存在;
5)用户可以根据停车场当前状态来给车辆分配车位;
6)有新车辆进入,用户可以往文件里增加信息;
7)用户可以根据不同需要查询他所需要的信息;
8)车辆离开时,用户可以根据车牌信息对这辆车进入时登记的信息进行查询,算出停车费
用,收取费用;
9)收取费用后,用户可以删除该辆车的信息;
10)用户在收费后,可以把收费金额添加到文件里,用户可以查看当日营业额;
四、总体设计
1.系统功能分析;
(1)初始化功能:用户第一次进入系统时,可以对停车场的基本信息进行设置,如车位数,有无忙闲时(忙闲时时段设置),有无车型分类(各种车型个数),收费制度,并把初始化信息储存在文件中;
(2)登记功能:车辆进入停车场时,对车辆的信息进行登记,信息包括车牌号,车型,车主电话号码,进入停车场的时间,将信息储存到文件;
(3)收费功能:车辆离开停车场时收费,填入车牌号,系统自动读取车辆进入时保存的信息,输入离开时的时间,系统根据收费制度进行收费,并删除该车的停车信息;
(4)查询功能:有四种查询方式,分别为整体查询、按车牌号查询、按车位号查询、按车主电话号码查询;
(5)账本功能:收费时将该车的收费金额累加到账本文件中,在整体查询时,显示今日营业额;
2.类的描述;
初始化类:为用户的初始化提供数据和函数;
车类:储存车辆的信息;
时间类:用以计算停车时间。

3.各功能菜单介绍;
主菜单可以进入下一级的“车辆进入时登记”、“车辆离开时收费”、“停车场状态查询”、“退出系统”四个子菜单。

“停车场状态查询”可以进入下级“整体查询”、“按车牌号查询”、“按车位号查询”、“按车主电话号码查询”。

4.系统功能模块的划分与设计,各功能函数的说明;
系统功能划分为四个:初始化模块,登记模块,收费模块,查询模块。

其中初始化模块只在用户第一次使用系统时执行。

登记函数:提示用户输入车辆信息,对用户输入的信息进行储存;
收费函数:读取车辆进入时保存的信息,对车辆进行收费;
五、详细设计与实现
1.各个类设计、实现与详细说明;
(1)初始化类
class chushihua //初始化类
{
public:
chushihua();
void chushi();
void money1();
void money2();
void money3();
void money4();
void shezhimangshi();
void showchushihua();
void shezhichexing();
void chucunmoneyint();
static float shoufei,shoufei1,shoufei2,shoufei3,mangshi,xianshi, //变量声明
mangshi1,mangshi2,mangshi3,xianshi1,xianshi2,xianshi3;
static int mang1,mang2;
int sum,sum1,sum2,sum3,moneyint;
};
(2)car类
class car{ //汽车类
public:
int cheweihao;
string chepai,shoujihao;
int chexing;
Time time1,time2;
car(string chepai="0",int hour1=0,int minute1=0,int cheweihao=0,int chexing=0,string shoujihao="0",int hour2=0,int
minute2=0):time1(hour1,minute1),time2(hour2,minute2){
this->chepai=chepai;
this->cheweihao=cheweihao;
this->chexing=chexing;
this->shoujihao=shoujihao;
}
void printftime1(){
car::time1.showtime();
}
void printftime2(){
car::time2.showtime();
}
static double zhangben1; //静态数据成员,实现今日总收入的计算};
car类定义了车辆的信息,在车辆离开时将车辆的信息从文件中读取出来,储存到car类里(3)Time类
class Time{ //时间类
public:
Time(int hour=0,int minute=0){
this->hour=hour;
this->minute=minute;
}
void settime(int hour,int minute){
this->hour=hour;
this->minute=minute;
}
void showtime(){
cout<<hour<<"时"<<minute<<"分"<<endl;
}
friend int totaltime(Time &t1,Time &t2); //友元函数以及函数的重载,实现时间相减(前者减去后者),求出总的时间
friend int totaltime(int mang,Time &t);
friend int totaltime(Time &t,int mang);
friend double money1(double shoufei,Time &t1,Time &t2); //不同情况时求停车费用的4个函数
friend double money2(double shoufei1,double shoufei2,double shoufei3,Time &t1,Time &t2,int chexing);
friend double money3(int mang1,int mang2,double mangshi,double xianshi,Time &t1,Time &t2);
friend double money4(int mang1,int mang2,double mangshi1,double
mangshi2,double mangshi3,double xianshi1,double xianshi2,double xianshi3,Time &t1,Time &t2,int chexing);
int hour,minute;
};
Time类用来计算停车时间
(4)car1类
class car1 //登记时用到的car1类
{
public:
char* inputchepai();
char* inputid();
int inputcheying();
int inputhour();
int inputmintue();
friend void shoufeixianshi();
friend void tianruxinxi();
friend void anpaichewei();
friend void cheweixianshi();
//private :
int chexing;
char chepai[100];
char id[100];
int hour;
int minute;
};
car1类用来给进入车辆登记
2.各函数的设计与实现(含流程图)与详细说明;
inline T fromString
inline T fromString(const string &str){
istringstream is(str);
T v;
is>>v;
return v;
}
四个重载函数int totaltime
int totaltime(Time &t1,Time &t2){ //参数为两个时间类的计算总的时间的函数int totalminute,totalhour,totaltime;
if(t1.minute<t2.minute){
t1.minute+=60;
t1.hour--;
totalminute=t1.minute-t2.minute;
}
else
totalminute=t1.minute-t2.minute;
if(t1.hour<t2.hour){
t1.hour+=24;
totalhour=t1.hour-t2.hour;
}
else
totalhour=t1.hour-t2.hour;
totaltime=totalhour*60+totalminute;
return totaltime;
}
int totaltime(int mang,Time &t){ //参数为忙时和时间类的计算总的时间的函数,前者减去后者来计算总的时间
int totalhour,totaltime;
totalhour=mang-t.hour;
totaltime=totalhour*60-t.minute;
return totaltime;
}
int totaltime(Time &t,int mang){ //参数为忙时和时间类的计算总的时间的函数,前者减去后者来计算总的时间
int totalhour,totaltime;
totalhour=t.hour-mang;
totaltime=totalhour*60+t.minute;
return totaltime;
}
int totaltime(int mang1,int mang2){ //参数为两个忙时的计算总的时间的函数return (mang1-mang2)*60;
}
double money1
double money1(double shoufei,Time &t1,Time &t2){ //对应于moneyint==1时的情况,即无忙闲时和车位大中小的设置,计算此种情况时停车的收费int totaltime1;
totaltime1=totaltime(t2,t1);
return totaltime1*shoufei;
}
double money2
double money2(double shoufei1,double shoufei2,double shoufei3,Time &t1,Time
&t2,int chexing){ //对应于moneyint==2时的情况,即无忙闲时而有停车位大中小之分的情况,计算此种情况时停车的收费
int totaltime1;
totaltime1=totaltime(t2,t1);
if(chexing==1)
return totaltime1*shoufei1;
else if(chexing==2)
return totaltime1*shoufei2;
else if(chexing==3)
return totaltime1*shoufei3;
else{
cout<<"money2函数中chexing数据出错!!"<<endl;
return 0;
}
}
double money3
double money3(int mang1,int mang2,double mangshi,double xianshi,Time &t1,Time &t2){ //对应于moneyint==3时的情况,即车位无大中小之分,而时间有忙闲时之分的情况,计算此种情况时停车的收费
if(t1.hour<mang1&&t2.hour<mang1||t1.hour>=mang2&&t2.hour>=mang2||t1.hour>=m ang2&&t2.hour<mang1){
return totaltime(t2,t1)*xianshi;
}
else if(t1.hour>=mang1&&t2.hour<mang2){
return totaltime(t2,t1)*mangshi;
}
else if(t1.hour<mang1&&t2.hour>=mang1&&t2.hour<mang2){
return totaltime(mang1,t1)*xianshi+totaltime(t2,mang1)*mangshi;
}
else if(t1.hour>=mang1&&t1.hour<mang2&&t2.hour>=mang2){
return totaltime(t2,mang2)*xianshi+totaltime(mang2,t1)*mangshi;
}
else if(t1.hour<mang1&&t2.hour>=mang2){
return
totaltime(mang1,t1)*xianshi+totaltime(t2,mang2)*xianshi+totaltime(mang2,mang1)* mangshi;
}
else{
cout<<"money3函数出错!!"<<endl;
return 0;
}
}
double money4
double money4(int mang1,int mang2,double mangshi1,double mangshi2,double mangshi3,double xianshi1,double xianshi2,double xianshi3,Time &t1,Time &t2,int chexing){ //对应于moneyint==34时的情况,即车位有大中小之分,时间有忙闲时之分的情况,计算此种情况时停车的收费
if(chexing==1){
if(t1.hour<mang1&&t2.hour<mang1||t1.hour>=mang2&&t2.hour>=mang2||t1.hour>=m ang2&&t2.hour<mang1){
return totaltime(t2,t1)*xianshi1;
}
else if(t1.hour>=mang1&&t2.hour<mang2){
return totaltime(t2,t1)*mangshi1;
}
else if(t1.hour<mang1&&t2.hour>=mang1&&t2.hour<mang2){
return totaltime(mang1,t1)*xianshi1+totaltime(t2,mang1)*mangshi1;
}
else if(t1.hour>=mang1&&t1.hour<mang2&&t2.hour>=mang2){
return totaltime(t2,mang2)*xianshi1+totaltime(mang2,t1)*mangshi1;
}
else if(t1.hour<mang1&&t2.hour>=mang2){
return
totaltime(mang1,t1)*xianshi1+totaltime(t2,mang2)*xianshi1+totaltime(mang2,mang1 )*mangshi1;
}
else{
cout<<"maney41ERROR!!"<<endl;
return 0;
}
}
else if(chexing==2){
if(t1.hour<mang1&&t2.hour<mang1||t1.hour>=mang2&&t2.hour>=mang2||t1.hour>=m ang2&&t2.hour<mang1){
return totaltime(t2,t1)*xianshi2;
}
else if(t1.hour>=mang1&&t2.hour<mang2){
return totaltime(t2,t1)*mangshi2;
}
else if(t1.hour<mang1&&t2.hour>=mang1&&t2.hour<mang2){
return totaltime(mang1,t1)*xianshi2+totaltime(t2,mang1)*mangshi2;
}
else if(t1.hour>=mang1&&t1.hour<mang2&&t2.hour>=mang2){
return totaltime(t2,mang2)*xianshi2+totaltime(mang2,t1)*mangshi2;
}
else if(t1.hour<mang1&&t2.hour>=mang2){
return
totaltime(mang1,t1)*xianshi2+totaltime(t2,mang2)*xianshi2+totaltime(mang2,mang1 )*mangshi2;
}
else{
cout<<"money42ERROR!!"<<endl;
return 0;
}
}
else if(chexing==3){
if(t1.hour<mang1&&t2.hour<mang1||t1.hour>=mang2&&t2.hour>=mang2||t1.hour>=m ang2&&t2.hour<mang1){
return totaltime(t2,t1)*xianshi3;
}
else if(t1.hour>=mang1&&t2.hour<mang2){
return totaltime(t2,t1)*mangshi3;
}
else if(t1.hour<mang1&&t2.hour>=mang1&&t2.hour<mang2){
return totaltime(mang1,t1)*xianshi3+totaltime(t2,mang1)*mangshi3;
}
else if(t1.hour>=mang1&&t1.hour<mang2&&t2.hour>=mang2){
return totaltime(t2,mang2)*xianshi3+totaltime(mang2,t1)*mangshi3;
}
else if(t1.hour<mang1&&t2.hour>=mang2){
return
totaltime(mang1,t1)*xianshi3+totaltime(t2,mang2)*xianshi3+totaltime(mang2,mang1 )*mangshi3;
}
else{
cout<<"money43ERROR!!"<<endl;
return 0;
}
}
else{
cout<<"money4函数中chexing数据出错!!"<<endl;
return 0;
}
}
double money
double money(int hour2,int minute2,car *c,int *a,string chepai){ //封装好的收费函数,在caidanshoufei函数中调用,它从moneyint文件中moneyint的值,通过判断moneyint的值,调用money1或money2或money3或money4函数,这几个函数的参数从chushihua这个文件中读取
int i,hour1,minute1,chexing=0,s,s1,s2,s3,moneyint,mang1=0,mang2=0;
double
money_,shoufei=0,shoufei1=0,shoufei2=0,shoufei3=0,mangshi=0,mangshi1=0,mangshi2 =0,mangshi3=0,xianshi=0,xianshi1=0,xianshi2=0,xianshi3=0;
string line;
ifstream myfile2("E:\\chushihua.txt");
if(myfile2){
getline(myfile2,line,'\n');
s=fromString<int>(line);
getline(myfile2,line,'\n');
s1=fromString<int>(line);
getline(myfile2,line,'\n');
s2=fromString<int>(line);
getline(myfile2,line,'\n');
s3=fromString<int>(line);
myfile2.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return 0;
}
ifstream myfile1("E:\\moneyint.txt"); //从moneyint文件中读取moneyint
if(myfile1){
getline(myfile1,line,'\n');
moneyint=fromString<int>(line);
myfile1.close();
}
else{
cout<<"不能打开moneyint文件!!"<<endl;
return 0;
}
for(i=0;i<s;i++){
if(a[i]==1){
if(c[i].chepai==chepai){
chexing=c[i].chexing;
hour1=c[i].time1.hour; //从car类的数组中读取时间,再将相应的信息置零,以实现汽车的离开
minute1=c[i].time1.minute;
a[i]=0;
c[i].chepai="0";
c[i].cheweihao=0;
c[i].time1.settime(0,0);
c[i].shoujihao="0";
break;
}
}
}
if(i>=s){
cout<<"没有这辆车!"<<endl;
return 0;
}
fstream my("E:\\shuju.txt",ios_base::out); //每次有车辆离开,即将car类的信息存入shuju文件中,以便退出系统再次调用时实现停车数据的恢复
for(i=0;i<s;i++){
if(a[i]==1){
my<<c[i].cheweihao<<endl;
my<<c[i].chepai<<endl;
my<<c[i].chexing<<endl;
my<<c[i].shoujihao<<endl;
my<<c[i].time1.hour<<endl;
my<<c[i].time1.minute<<endl;
}
}
fstream myfile41("E:\\chewei1.txt",ios_base::out);
fstream myfile42("E:\\chewei2.txt",ios_base::out);
fstream myfile43("E:\\chewei3.txt",ios_base::out);
if(moneyint==1||moneyint==3){
for(i=0;i<s;i++){
if(a[i]==0){
break;
}
}
myfile41<<i+1;
}
else if(moneyint==2||moneyint==4){
if(chexing==1){
for(i=s1-1;i<s2-1;i++){
if(a[i]==0){
break;
}
}
myfile41<<i+1;
}
else if(chexing==2){
for(i=s2-1;i<s3-1;i++){
if(a[i]==0){
break;
}
}
myfile42<<i+1;
}
else if(chexing==3){
for(i=s3-1;i<s;i++){
if(a[i]==0){
break;
}
}
myfile43<<i+1;
}
else{
cout<<"money函数中chexing数据错误!!"<<endl;
return 0;
}
}
else{
}
Time t1(hour1,minute1);
Time t2(hour2,minute2);
ifstream myfile21("E:\\chushihua.txt");
ifstream myfile22("E:\\chushihua.txt");
ifstream myfile23("E:\\chushihua.txt");
ifstream myfile24("E:\\chushihua.txt");
switch(moneyint){
case 1: //moneyint为1的情况if(myfile21){
getline(myfile21,line,'\n');
getline(myfile21,line,'\n');
shoufei=fromString<double>(line);
myfile21.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return 0;
}
money_=money1(shoufei,t1,t2);
car::zhangben1+=money_;
return money_;
break;
case 2: //moneyint为2的情况
if(myfile22){
getline(myfile22,line,'\n');
getline(myfile22,line,'\n');
getline(myfile22,line,'\n');
getline(myfile22,line,'\n');
getline(myfile22,line,'\n');
shoufei1=fromString<double>(line);
getline(myfile22,line,'\n');
shoufei2=fromString<double>(line);
getline(myfile22,line,'\n');
shoufei3=fromString<double>(line);
myfile22.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return 0;
}
money_=money2(shoufei1,shoufei2,shoufei3,t1,t2,chexing);
car::zhangben1+=money_;
return money_;
break;
case 3: //moneyint为3的情况if(myfile23){
getline(myfile23,line,'\n');
getline(myfile23,line,'\n');
mang1=fromString<int>(line);
getline(myfile23,line,'\n');
mang2=fromString<int>(line);
getline(myfile23,line,'\n');
mangshi=fromString<double>(line);
getline(myfile23,line,'\n');
xianshi=fromString<double>(line);
myfile23.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return 0;
}
money_=money3(mang1,mang2,mangshi,xianshi,t1,t2);
car::zhangben1+=money_;
return money_;
break;
case 4: //moneyint为4的情况if(myfile24){
getline(myfile24,line,'\n');
getline(myfile24,line,'\n');
getline(myfile24,line,'\n');
getline(myfile24,line,'\n');
getline(myfile24,line,'\n');
mang1=fromString<int>(line);
getline(myfile24,line,'\n');
mang2=fromString<int>(line);
getline(myfile24,line,'\n');
mangshi1=fromString<double>(line);
getline(myfile24,line,'\n');
mangshi2=fromString<double>(line);
getline(myfile24,line,'\n');
mangshi3=fromString<double>(line);
getline(myfile24,line,'\n');
xianshi1=fromString<double>(line);
getline(myfile24,line,'\n');
xianshi2=fromString<double>(line);
getline(myfile24,line,'\n');
xianshi3=fromString<double>(line);
myfile24.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return 0;
}
money_=money4(mang1,mang2,mangshi1,mangshi2,mangshi3,xianshi1,xianshi2,xian shi3,t1,t2,chexing);
car::zhangben1+=money_;
return money_;
break;
}
}
void fenpei
void fenpei(car *c,int *a){ //这个函数要结合娄旸的代码来调用,它会读取娄旸写好的data文件,从中读取car类所需要的相应信息,然后再将它们保存到我所建立的car类的一个数组次c【s】中
int i,s,s1,s2,s3,hour1,minute1,chexing,moneyint;
string line,chepai,shoujihao;
ifstream myfile1("E:\\moneyint.txt");
if(myfile1){
getline(myfile1,line,'\n');
moneyint=fromString<int>(line);
myfile1.close();
}
else{
cout<<"不能打开moneyint文件!!"<<endl;
return;
}
ifstream myfile2("E:\\chushihua.txt");
if(myfile2){
getline(myfile2,line,'\n');
s=fromString<int>(line);
getline(myfile2,line,'\n');
s1=fromString<int>(line);
getline(myfile2,line,'\n');
s2=fromString<int>(line);
getline(myfile2,line,'\n');
s3=fromString<int>(line);
myfile2.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return;
}
ifstream myfile3("E:\\data.txt"); //从data文件中读取相应相应数据
if(myfile3){
getline(myfile3,line,'\n');
chepai=line;
getline(myfile3,line,'\n');
chexing=fromString<int>(line);
getline(myfile3,line,'\n');
shoujihao=line;
getline(myfile3,line,'\n');
hour1=fromString<int>(line);
getline(myfile3,line,'\n');
minute1=fromString<int>(line);
myfile3.close();
}
else{
cout<<"不能打开data文件!!"<<endl;
return;
}
if(moneyint==1||moneyint==3){ //分配车位,并将车位号写入chewei1,chewei2,chewei3文件中
fstream myfile40("E:\\chewei1.txt",ios_base::out);
for(i=0;i<s;i++){
if(a[i]==0){
a[i]=1;
c[i].chepai=chepai;
c[i].cheweihao=i+1;
c[i].time1.settime(hour1,minute1);
c[i].shoujihao=shoujihao;
c[i].chexing=chexing;
break;
}
}
if(i+1>s){
myfile40.close();
return;
}
myfile40<<i+1;
myfile40.close();
}
else if(moneyint==2||moneyint==4){
if(chexing==1){
fstream myfile41("E:\\chewei1.txt",ios_base::out);
for(i=s1-1;i<s2-1;i++){
if(a[i]==0){
a[i]=1;
c[i].chepai=chepai;
c[i].cheweihao=i+1;
c[i].time1.settime(hour1,minute1);
c[i].shoujihao=shoujihao;
c[i].chexing=chexing;
break;
}
}
if(i+1>s2-1){
myfile41.close();
return;
}
myfile41<<i+1;
myfile41.close();
}
else if(chexing==2){
fstream myfile42("E:\\chewei2.txt",ios_base::out);
for(i=s2-1;i<s3-1;i++){
if(a[i]==0){
a[i]=1;
c[i].chepai=chepai;
c[i].cheweihao=i+1;
c[i].time1.settime(hour1,minute1);
c[i].shoujihao=shoujihao;
c[i].chexing=chexing;
break;
}
}
if(i+1>s3-1){
myfile42.close();
return;
}
myfile42<<i+1;
myfile42.close();
}
else if(chexing==3){
fstream myfile43("E:\\chewei3.txt",ios_base::out);
for(i=s3-1;i<s;i++){
if(a[i]==0){
a[i]=1;
c[i].chepai=chepai;
c[i].cheweihao=i+1;
c[i].time1.settime(hour1,minute1);
c[i].shoujihao=shoujihao;
c[i].chexing=chexing;
break;
}
}
if(i+1>s){
myfile43.close();
return;
}
myfile43<<i+1;
myfile43.close();
}
else{
cout<<"fenpei函数中chexing数据错误!!"<<endl;
return;
}
}
else{
cout<<"fenpei函数中moneyint数据错误!!"<<endl;
return;
}
fstream my("E:\\shuju.txt",ios_base::out); //每次分配完车位后,就将car类的信息保存到shuju文件中
for(i=0;i<s;i++){
if(a[i]==1){
my<<c[i].cheweihao<<endl;
my<<c[i].chepai<<endl;
my<<c[i].chexing<<endl;
my<<c[i].shoujihao<<endl;
my<<c[i].time1.hour<<endl;
my<<c[i].time1.minute<<endl;
}
}
}
void dushuju
void dushuju(car *c,int *a){ //从E盘的shuju文件中读取数据,存放在car 类中,用来在系统再次打开时实现停车数据的恢复
string line,chepai,shoujihao;
int cheweihao,chexing,hour1,minute1,j;
ifstream my("E:\\shuju.txt");
if(my){
while(getline(my,line,'\n')){
cheweihao=fromString<int>(line);
getline(my,line,'\n');
chepai=line;
getline(my,line,'\n');
chexing=fromString<int>(line);
getline(my,line,'\n');
shoujihao=line;
getline(my,line,'\n');
hour1=fromString<int>(line);
getline(my,line,'\n');
minute1=fromString<int>(line);
j=cheweihao-1;
a[j]=1;
c[j].chepai=chepai;
c[j].cheweihao=j+1;
c[j].time1.settime(hour1,minute1);
c[j].shoujihao=shoujihao;
c[j].chexing=chexing;
}
}
}
void totalchewei
void totalchewei(car *c,int *a){ //计算现在整个停车场中所停车的总数,如果有大中小车位之分,还会分别计算每种车的数量
int i,total=0,s,s1=0,s2=0,s3=0,moneyint;
string line;
ifstream myfile1("E:\\moneyint.txt"); //从moneyint文件中读取moneyint
if(myfile1){
getline(myfile1,line,'\n');
moneyint=fromString<int>(line);
myfile1.close();
}
else{
cout<<"不能打开moneyint文件!!"<<endl;
return;
}
ifstream myfile2("E:\\chushihua.txt");
if(moneyint==2||moneyint==4){
if(myfile2){
getline(myfile2,line,'\n');
s=fromString<int>(line);
getline(myfile2,line,'\n');
s1=fromString<int>(line);
getline(myfile2,line,'\n');
s2=fromString<int>(line);
getline(myfile2,line,'\n');
s3=fromString<int>(line);
myfile2.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return;
}
}
else if(moneyint==3||moneyint==1){
if(myfile2){
getline(myfile2,line,'\n');
s=fromString<int>(line);
myfile2.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return;
}
}
else{
cout<<"totalweiche函数中moneyint错误!!"<<endl;
return;
}
fstream f1("E:\\total1.txt");
fstream f2("E:\\total2.txt");
fstream f3("E:\\total3.txt");
if(moneyint==1||moneyint==3){ //无大中小车位之分时计算全部车辆 for(i=0;i<s;i++){
if(a[i]==1)
total++;
}
f1<<total;
f1.close();
}
else if(moneyint==2||moneyint==4){ //分别计算大中小车辆的数量 for(i=s1-1;i<s2-1;i++){
if(a[i]==1)
total++;
}
f1<<total;
f1.close();
total=0;
for(i=s2-1;i<s3-1;i++){
if(a[i]==1)
total++;
}
f2<<total;
f2.close();
total=0;
for(i=s2-1;i<s;i++){
if(a[i]==1)
total++;
}
f3<<total;
f3.close();
}
else{
cout<<"totalchewei函数中moneyint错误!!"<<endl;
return;
}
}
void totalsearch
void totalsearch(car *c,int *a){ //整体查询函数,将整个停车场的情况显示出来int i,s;
string line;
ifstream myfile2("E:\\chushihua.txt");
if(myfile2){
getline(myfile2,line,'\n');
s=fromString<int>(line);
myfile2.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return;
}
cout<<"******************************************************************"< <endl;
cout<<"现在是整体查询:"<<endl<<endl;
cout<<"||"<<"车位号 "<<"||"<<"车牌号 "<<"||"<<"驶入时间"<<endl;
for(i=0;i<s;i++){
if(a[i]==1){
cout<<"||";
cout.width(3);
cout<<i+1;
cout.width(15);
cout<<"||";
cout<<setiosflags(ios_base::left)<<setw(16)<<c[i].chepai;
cout<<"||";
c[i].printftime1();
cout<<resetiosflags(ios_base::left);
}
else if(a[i]==0){
cout<<"||";
cout.width(3);
cout<<i+1;
cout.width(15);
cout<<"||"<<"空";
cout.width(16);
cout<<"||"<<"空";
cout<<endl;
}
}
cout<<"******************************************************************"< <endl;
zhangben();
}
void cheweihaosearch
void cheweihaosearch(car *c,int *a,int cheweihao){ //按车位号查询的函数int i;
cout<<"******************************************************************"<<end l;
cout<<"现在是按车位号查询:"<<endl<<endl;
i=cheweihao-1;
if(a[i]==1){
cout<<"该车位所停车的车牌号为:"<<c[i].chepai<<endl<<"其驶入时间为:";
c[i].printftime1();
}
else if(a[i]==0)
cout<<"该车位未停车."<<endl;
else
cout<<"ERROR!!"<<endl;
cout<<"******************************************************************"< <endl;
}
void chepaisearch
void chepaisearch(car *c,int *a,string chepai){ //按车牌号查询的函数int i,s;
string line;
ifstream myfile2("E:\\chushihua.txt");
if(myfile2){
getline(myfile2,line,'\n');
s=fromString<int>(line);
myfile2.close();
}
else{
cout<<"不能打开chushihua文件!!"<<endl;
return;
}
cout<<"******************************************************************"< <endl;
cout<<"现在是按车牌号查询:"<<endl<<endl;
for(i=0;i<s;i++){
if(a[i]==1){
if(c[i].chepai==chepai){。

相关文档
最新文档