欢迎来到天天文库
浏览记录
ID:55631028
大小:18.00 KB
页数:4页
时间:2020-05-21
《c++面向对象程序设计实现简单电梯.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、head.h#include#include#include#include#includeusingnamespacestd;classdate{private:intd,m,y;public:date();voidadd();};classCelevator{private:intfl;public:Celevator();voidchoose();voidup(intx);voiddown(intx);};elevator.cpp#include"head.h"#include
2、date::date(){time_tnow;time(&now);structtm*t_now;t_now=localtime(&now);y=t_now->tm_year+1900;m=t_now->tm_mon+1;d=t_now->tm_mday;}voiddate::add(){cout<<"Todayis"<3、(){datetime;time.add();fl=1;cout<4、1.up5、"<6、2.down7、"<8、0.quit9、"<>n;if(n==1){cout<<"Pleaseenterthefloors:"<10、x;cin>>x;Celevator::up(x);}if(n==2){cout<<"Pleaseenterthefloors:"<>x;Celevator::down(x);}if(n==0){exit(0);}}voidCelevator::up(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x<=i){cout<<"Inputerror"<11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
3、(){datetime;time.add();fl=1;cout<4、1.up5、"<6、2.down7、"<8、0.quit9、"<>n;if(n==1){cout<<"Pleaseenterthefloors:"<10、x;cin>>x;Celevator::up(x);}if(n==2){cout<<"Pleaseenterthefloors:"<>x;Celevator::down(x);}if(n==0){exit(0);}}voidCelevator::up(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x<=i){cout<<"Inputerror"<11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
4、1.up
5、"<6、2.down7、"<8、0.quit9、"<>n;if(n==1){cout<<"Pleaseenterthefloors:"<10、x;cin>>x;Celevator::up(x);}if(n==2){cout<<"Pleaseenterthefloors:"<>x;Celevator::down(x);}if(n==0){exit(0);}}voidCelevator::up(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x<=i){cout<<"Inputerror"<11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
6、2.down
7、"<8、0.quit9、"<>n;if(n==1){cout<<"Pleaseenterthefloors:"<10、x;cin>>x;Celevator::up(x);}if(n==2){cout<<"Pleaseenterthefloors:"<>x;Celevator::down(x);}if(n==0){exit(0);}}voidCelevator::up(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x<=i){cout<<"Inputerror"<11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
8、0.quit
9、"<>n;if(n==1){cout<<"Pleaseenterthefloors:"<10、x;cin>>x;Celevator::up(x);}if(n==2){cout<<"Pleaseenterthefloors:"<>x;Celevator::down(x);}if(n==0){exit(0);}}voidCelevator::up(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x<=i){cout<<"Inputerror"<11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
10、x;cin>>x;Celevator::up(x);}if(n==2){cout<<"Pleaseenterthefloors:"<>x;Celevator::down(x);}if(n==0){exit(0);}}voidCelevator::up(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x<=i){cout<<"Inputerror"<11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
11、x<<"floorhasbarrived"<12、1.up13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
12、1.up
13、"<14、2.down15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
14、2.down
15、"<16、0.quit17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
16、0.quit
17、"<18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
18、:choose();}voidCelevator::down(intx){if((x>=-3)&&(x<=20)){inti=fl;if(x>=i){cout<<"Inputerror"<x;i--){cout<<"Youareonthe"<19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
19、cout<<"Thiselevatorfrom-3to20floors"<20、1.up21、"<22、2.down23、"<24、0.quit25、"<
20、1.up
21、"<22、2.down23、"<24、0.quit25、"<
22、2.down
23、"<24、0.quit25、"<
24、0.quit
25、"<
此文档下载收益归作者所有