. .
:
1) , . , , 1 ;
2) , ;
3) , ;
4) , ; , ;
5) , ;
6) : , ;
7) , .
, .
:
1) / ;
2) / ;
3) / ;
4) .
():
1) ;
2) ;
3) .
stove.h
enum state {on, off}; // , /
enum door {open, close}; // , /
class stove
{ state curr_lamp; //
door curr_door; //
state curr_power; //
int time; //,
void take_door(void); //,
void push_button(void); //,
void ready(void); //,
public:
stove(); //,
void Run(); //,
};
stove.cpp
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include "stove.h"
void menu() //
{
printf("\n%b - \n");
printf("d - / \n");
printf("ESC - \n\n");
}
stove::stove()
{
// :
curr_lamp=off; //
curr_door=close; //
curr_power=off; //
time=-1; //
}
void stove::take_door(void)
{
if (curr_door==open) //
{ curr_door=close; //
curr_lamp=off; //
printf(" \n");
}
else //
{ curr_door=open; //
curr_lamp=on; //
|
|
printf(" \n");
if (curr_power==on) //
{
printf(" \n");
time=-1; //
curr_power=off; //
}
}
return;
}
void stove::push_button(void)
{
if (curr_door==open) // ,
printf(" !\n");
else //
{ if (curr_power==on) //
{ time+=60; //
printf(" \n");
}
else //
{ curr_power=on; //
curr_lamp=on; //
time=60; //
printf(" \n");
}
}
return;
}
void stove::ready(void)
{
//
curr_power=off; //
curr_lamp=off; //
time=-1; //
printf("\a \n");
}
void stove::Run(void)
{
int key;
do
{
while (!kbhit() && time>0) // , ;
:
// kbhit() ,
{
time--; // ,
Sleep(100); // 100
printf(" %d \n",time);
}
if (time==0) // , ready()
ready();
menu();
key=getch();
switch (key)
{ case 'b': push_button(); break;
case 'd': take_door(); break;
}
fflush(stdin);
}
while(key!=27);
return;
}