加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
building.cpp 6.23 KB
一键复制 编辑 原始数据 按行查看 历史
王陸 提交于 2021-04-28 16:10 . first commit
#include <iostream>
#include <string>
#include "windows.h"
#include "elevator.h"
using namespace std;
building::building(int mf)
{
MF=mf;
}
building::~building()
{
}
int building::get_mf()
{
return MF;
}
void building::dis_b()
{
int i;
cout<<"\n";
cout<<" ******电梯系统******"<<endl;
cout<<"\n";
for(i=9; i>=1; i--)
{
cout<<" ===================="<<endl;//20
if(E.get_now()==i)//到达的楼层设置为红色
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<" |*******电梯*******|"<<endl;
cout<<i<<" |******************|";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
if(E.get_out(i)==1)//该楼层有向上的请求
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<i<<"上"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else if(E.get_out(i)==2)//该楼层有向下的请求
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<i<<"下"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else if(E.get_out(i)==3)//该楼层既有向下的请求,又有向上的请求
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<i<<"上-下"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<endl;
}
}
else
{
cout<<" | |"<<endl;
cout<<i<<" | |";
if(E.get_out(i)==1)//该楼层有向上的请求
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<i<<"上"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else if(E.get_out(i)==2)//该楼层有向下的请求
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<i<<"下"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else if(E.get_out(i)==3)//该楼层既有向下的请求,又有向上的请求
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<i<<"上-下"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<endl;
}
}
}
cout<<" ===================="<<endl<<endl;//20
}
void building::dis_vew()
{
cout<<" ****电梯内按钮****"<<endl;
cout<<" ===========";
if(E.get_status()==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<" 上"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<" 上"<<endl;
}
if(E.get_button(1)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<" 1 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<" 1 ";
}
if(E.get_button(2)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<"2 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<"2 ";
}
if(E.get_button(3)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<"3 "<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<"3 "<<endl;
}
if(E.get_button(4)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<" 4 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<" 4 ";
}
if(E.get_button(5)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<"5 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<"5 ";
}
if(E.get_button(6)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<"6 "<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<"6 "<<endl;
}
if(E.get_button(7)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<" 7 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<" 7 ";
}
if(E.get_button(8)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<"8 ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<"8 ";
}
if(E.get_button(9)==1)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<"9 "<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<"9 "<<endl;
}
cout<<" ===========";
if(E.get_status()==2)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
cout<<" 下"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);//还原为白色
}
else
{
cout<<" 下"<<endl;
}
cout<<" ===================="<<endl;//20
int i;
for(i=1; i<=E.counts; i++)
{
if(E.p[i].in_floor==1)
{
cout<<" ";
cout<<E.p[i].id<<" from "<<E.p[i].from_floor<<" -> "<<E.p[i].to_floor<<endl;
}
}
cout<<" ===================="<<endl;//20
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化