c汽车租赁管理系统内容摘要:

//归还操作 void print() { cout 汽车原编号: setw(6) no \t 汽车原名称 : setw(18) name \t setw(10) (onshelf==1? 在车库 :已租 ) endl。 } //输出汽车 void disp() { cout setw(6) no setw(18) name setw(10) (onshelf==1? 在车库 :已租 ) endl。 } //显示 void disp(int k) { cout编号为 noendl。 } }。 templateclass T class biaozhiq { public: T abaso。 }。 //汽车库类,实现对汽车的管理,查找,删除等 class CarDatabase { public: int top。 //汽车记录指针 Car che[Maxc]。 //汽车记录 CarDatabase() { Car b。 top=1。 fstream file(,ios::in)。 while (1) { ((char *)amp。 b,sizeof(b))。 if (!file) break。 top++。 che[top]=b。 } ()。 } //构造函数,将 che[]中 void clear()//全删 { top=1。 } int addcar(int n,char *na)。 //增加汽车 Car *query(int carid) { for (int i=0。 i=top。 i++) if (che[i].getno()==carid amp。 amp。 che[i].gettag()==0) { return amp。 che[i]。 } return NULL。 } //查找汽车 void cardata()。 //汽车库管理 virtual void print(int n) { for(int i=0。 i=top。 i++) if(che[i].getno()==n) che[i].print()。 } //输出原汽车 void disp() { for (int i=0。 i=top。 i++) if (che[i].gettag()==0) che[i].disp()。 } //显示 ~CarDatabase()。 //析构函数,将 che[]写到 文件中 }。 int CarDatabase::addcar(int n,char *na) { Car *p=query(n)。 if (NULL==p) { top++。 che[top].addcar(n,na)。 return 1。 } return 0。 } //增加汽车 CarDatabase::~CarDatabase() { fstream file(,ios::out)。 for (int i=0。 i=top。 i++) if (che[i].gettag()==0) ((char *)amp。 che[i],sizeof(che[i]))。 ()。 ofstream f(c:\\)。 for (int j=0。 j=top。 j++) { if(che[j].gettag()==0) f编号。 fche[j].no。 f\t\t\t。 f汽车。 fche[j].name。 f\t\t\t。 if(che[j].onshelf==1) f在车库 endl。 else f已出租 endl。 } } //析构函数,将 che[]写到 文件中 //汽车管理 void CarDatabase::cardata() { char choice。 char ame[20]。 int carid。 Car *b。 do { cout \n\n\n\t\t\t欢迎进入汽车管理界面 endlendl。 cout\t\tendl。 cout\t\t| 1 增加汽车 |endl。 cout\t\t| 2 更改汽车 |endl。 cout\t\t| 3 删除汽车 |endl。 cout\t\t| 4 查找汽车 |endl。 cout\t\t| 5 查看全部 |endl。 cout\t\t| 6 删除全部 |endl。 cout\t\t| 0 返回上一层 |endl。 cout\t\tendl。 cin choice。 switch (choice) { case 39。 139。 : cout 新增 \n 输入汽车编号 :endl。 cin carid。 try { if(carid=0)throw 1。 } catch(...) { cout输入有误,请重新 输入。 break。 } cout 输入汽车名称 :endl。 cin ame。 addcar(carid,ame)。 break。 case 39。 239。 : cout 更改 \n 输入汽车编号 :endl。 cin carid。 try { if(carid=0)throw 1。 } catch(...) { cout输入有误,请重新输入。 break。 } b=query(carid)。 if (b==NULL) { cout 该汽车不存在。 coutendl。 break。 } print(carid)。 cout 输入新的汽车编号 :。 coutendl。 cincarid。 try { if(carid=0)throw 1。 } catch(...) { cout输入有误,请重新输入。 break。 } cout 输入新的汽车名称 :endl。 cin ame。 baddcar(carid,ame)。 cout修改成功 !endl。 break。 case 39。 339。 : cout 删除 \n 读入汽车编号 :endl。 cin carid。 try { if(carid=0)throw 1。 } catch(...) { cout输入有误,请重新输入。 break。 } b=quer。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。