📄 simulation.cpp
字号:
# ifndef _SIMULATION_H
# define _SIMULATION_H
# endif
# include <iostream.h>
# include "simulation.h"
# include <conio.h>
# include "draw_win.h"
simulation::simulation()
{
timeSimulate=36000;
timeRemaining=timeSimulate;
}
bool simulation::continues(void)
{
if (timeRemaining>0)
return true;
else
return false;
}
void simulation::SetTime(long secs)
{
timeSimulate=secs;
timeRemaining=timeSimulate;
}
long simulation::getTime(void) {return timeRemaining;}
void simulation::reduceTime(long secs)
{
if (secs>timeRemaining)
timeRemaining=0;
else
timeRemaining-=secs;
}
void simulation::perform(void)
{
cout<<"Simulation! Press <Space> to contimue";
while (getch()==' ') reduceTime(600);
}
void simulation::display(void)
{
cout<<endl<<"Timeremaining";
cout<<timeRemaining<<"secs";
}
void simulation::results(void)
{
char buffer[4096];
char main[4000];
gettext(1,1,80,25,buffer);
clrscr();
Draw_window (14,6,60,19);
gotoxy(15,7);
textcolor(RED);
cprintf("---------&**& Simulation results &**&--------");
gotoxy(15,9);
textcolor(YELLOW);
cprintf("Time at start:");
cout<<ctime(&starttime);
gotoxy(15,10);
endtime=time(NULL);
cprintf("Time at end:");
cout<<ctime(&endtime);
gotoxy(15,11);
cprintf("Sun time:");
cout<<difftime(endtime,starttime);
textcolor(RED);
gotoxy(17,13);
cprintf("totalPeople:");
cout<<totalPeople;
gotoxy(42,13);
cprintf("inBuilding:");
cout<<inBuilding;
gotoxy(17,14);
cprintf("leftBuilding:");
cout<<leftBuilding;
gotoxy(42,14);
cprintf("avgWait:");
cout<<avgwait;
gotoxy(17,15);
cprintf("avgRide:");
cout<<avgRide;
gotoxy(42,15);
cprintf("tookstair:");
cout<<tookstair;
gotoxy(17,16);
cprintf("MAXFLOORS:");
cout<<MAXFLOORS;
gotoxy(42,16);
cprintf("MAXEFEVS:");
cout<<MAXELEVS;
gotoxy(15,17);
textcolor(12);
cprintf("See last picture press <S>");
gotoxy(40,18);
textcolor(CYAN+BLINK);
cprintf("press <Q> to quit...");
while (!kbhit())
{
if (getch()=='s')
{
gettext(14,6,60,19,main);
clrscr();
puttext(1,1,80,25,buffer);
gotoxy(1,25);
textcolor(RED+BLINK);
cprintf("Press Any Key To Back...");
getch();
clrscr();
puttext(14,6,60,19,main);
}
if (getch()=='q') return;
}
textcolor(WHITE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -