#include <iostream>
#include <cstring>
#include <iomanip>
#include <conio.h>
#include <windows.h>
#include <time.h>
using namespace std;
class microwave
{
public:
char menuB; // 메뉴 버튼
char powerB; // 파워 버튼
int door; // 문 열림 / 닫힘 상태 표현
int powerSet; // 출력 설정 여부 확인 변수
int powerNum; // 출력 단계
int time_;// 시간 단계
int sec_;// 시간 (초)
int mod; // 모드 설정 변수
char error[20]; // 에러메시지 창
char ledPower[5]; // 출력 단계 표시창
char poweron[10]; // 전원 켜짐 표시창
char dooron[10]; // 문열림 표시창
microwave()
{
powerB='f';
menuB=0;
door=1;
}
/************************
* 세기 조절 *
* -> 강,중,약으로 전환 *
************************/
void ConPower(int a)
{
switch(a)
{
case 1 : strcpy_s(ledPower,"강 "); break;
case 2 : strcpy_s(ledPower,"중 "); break;
case 3 : strcpy_s(ledPower,"약 "); break;
}
return;
}
/************************
* 입력받은 time을 *
* sec로 전환 *
************************/
void SetSec()
{
cout<<"시간을 입력해주세요(1. 5초┃2.10초┃3.20초)"<<endl;
cin>>time_;
if(time_==1)
{
sec_+= 5;
time_=0;
}
if(time_==2)
{
sec_+= 10;
time_=0;
}
if(time_==3)
{
sec_+= 20;
time_=0;
}
}
/************************
* 모드 설정 *
* 간단하게 설정 가능 *
************************/
void SetMod(int mod1)
{
switch (mod1)
{
case 1 : powerNum=1,sec_=20;break;
case 2 : powerNum=2,sec_=10;break;
case 3 : powerNum=3,sec_=5;break;
case 4 : break;
}
}
/************************
* 시간 함수 *
* *
************************/
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
/************************
* 타이머 *
* *
************************/
void time_go(int sec_)
{
int i;
for (i=sec_; i>0; i--)
{
cout<<"\r"<<i;
wait (1);
}
cout<<"\rEND"<<endl;
}
/************************
* 시작 함수 *
* *
************************/
void startm();
};
void main()
{
microwave* mw_;
mw_ = new microwave;
mw_->startm();
delete mw_;
}
void microwave::startm()
{
while(1)
{
while(powerB!='o')
{
cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ Power OFF ┃ ON/OFF = o/f ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ 5 초 ┃ 10초 ┃ 20초 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ 강 ┃ 중 ┃ 약 ┃"<<endl;
cout<<"┃ x.종료 ┃ ┃"<<endl;
cout<<"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"<<endl;
cout<<"전원 버튼을 눌러주세요(o/f)"<<endl;
cin>>powerB;
if(powerB=='o')
{
system("cls");
continue;
}
else if(powerB=='f')
{
system("cls");
continue;
}
else if(powerB=='x')
{ exit(1);
}
system("cls");
}
strcpy_s(error," ");
strcpy_s(ledPower," ");
sec_=0;
powerSet=0;
while(powerB!='f')
{
if(powerB=='o')
strcpy_s(poweron,"ON");
else if(powerB=='f')
strcpy_s(poweron,"OFF");
if(door==0)
{
strcpy_s(dooron,"DOOR OPEN");
}
else if(door==1)
{
strcpy_s(dooron," ");
}
cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ Power"<<setw(4)<<poweron<<" ┃"<<setw(10)<<ledPower<<"┃"<<setw(10)<<sec_<<"┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ "<<setw(10)<<dooron<<" ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ "<<setw(20)<<error<<" ┃ ┃"<<endl;
cout<<"┃ ┃1. 5초┃2.10초┃3.20초┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ==메뉴== ┃ ┃"<<endl;
cout<<"┃ 1.시간 ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ 2.출력 x.종료 ┃ ┃"<<endl;
cout<<"┃ 3.모드 p.동작 ┃ 1.강 ┃ 2.중 ┃ 3.약 ┃"<<endl;
cout<<"┃ o/f.전원 (On/Off) 문 열기/닫기 (m/n) ┃ ┃"<<endl;
cout<<"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"<<endl;
cout<<"메뉴를 눌러주세요"<<endl;
cin>>menuB;
if (menuB=='f')
powerB='f';
else if(powerB=='f')
{
cout<<"전원이 꺼져있습니다."<<endl;
system("pause");
system("cls");
continue;
}
else if(menuB=='1')
{
SetSec();
system("cls");
continue;
}
else if(menuB=='2')
{
cout<< "세기번호를 눌러주세요. (1.강 ┃ 2.중 ┃ 3.약)"<<endl;
cin>>powerNum;
ConPower(powerNum);
system("cls");
powerSet=1;
continue;
}
else if(menuB=='3')
{
while(1)
{
cout<<"모드를 설정해주세요.모드 보기는 4번,돌아가기는 5번입니다."<<endl;
cin>>mod;
if(mod==5)
{
break;
}
else if (mod==4)
{
cout<<"┏1번 모드 : 강 / 20초"<<endl;
cout<<"┃2번 모드 : 중 / 10초"<<endl;
cout<<"┗3번 모드 : 약 / 5초"<<endl;
}
else
{
SetMod(mod);
ConPower(powerNum);
break;
}
}
system("cls");
continue;
}
else if(menuB=='r')
{
strcpy_s(ledPower," ");
strcpy_s(error," ");
sec_=0;
}
else if(menuB=='m')
{
door = 0;
system("cls");
}
else if(menuB=='n')
{ door = 1;
strcpy_s(error," ");
system("cls");
}
else if(menuB=='p')
{
if(door==1 && sec_>1)
{//동작
if(powerSet==1)
{
strcpy_s(error," ");
for (sec_; sec_>0; sec_--)
{
if(sec_%2==0)
{
system("cls");
cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ Power"<<setw(4)<<poweron<<" ┃"<<setw(10)<<ledPower<<"┃"<<setw(10)<<sec_<<"┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ "<<setw(10)<<dooron<<" ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ "<<setw(20)<<error<<"┃ ┃"<<endl;
cout<<"┃ ┏ ┃ 5 초 ┃ 10초 ┃ 20초 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ 작동중 ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┛ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ 강 ┃ 중 ┃ 약 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"<<endl;
}
if(sec_%2!=0)
{
system("cls");
cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ Power"<<setw(4)<<poweron<<" ┃"<<setw(10)<<ledPower<<"┃"<<setw(10)<<sec_<<"┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ "<<setw(10)<<dooron<<" ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ "<<setw(20)<<error<<"┃ ┃"<<endl;
cout<<"┃ ┓ ┃ 5 초 ┃ 10초 ┃ 20초 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ 작동중 ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┗ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ 강 ┃ 중 ┃ 약 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"<<endl;
}
wait(1);
}
if(sec_==0)
{
system("cls");
cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ Power"<<setw(4)<<poweron<<" ┃"<<setw(10)<<ledPower<<"┃"<<setw(10)<<sec_<<"┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ "<<setw(10)<<dooron<<" ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ "<<setw(20)<<error<<"┃ ┃"<<endl;
cout<<"┃ ┃ 5 초 ┃ 10초 ┃ 20초 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ = = 작동 완료 = = ┃ ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃━━━━━━━━━━━┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┃ ┃ 강 ┃ 중 ┃ 약 ┃"<<endl;
cout<<"┃ ┃ ┃"<<endl;
cout<<"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"<<endl;
strcpy_s(ledPower," ");
powerSet=0;
sec_=0;
}
}
else if (door==0)
//문닫으세요
strcpy_s(error,"문 열림");
else if (powerSet!=1)
{
strcpy_s(error,"출력/시간 설정");
}
}
else if (sec_==0)
{
strcpy_s(error,"출력/시간 설정");
}
system("pause");
}
else if(menuB=='x')
{ exit(1);
}
else
system("pause");
system("cls");
continue;
}
}
}
'[ IT ] > C++, 자료구조' 카테고리의 다른 글
C++ Gotoxy 함수 (0) | 2015.06.24 |
---|---|
C++ 파일 분할 (1) | 2015.06.24 |
C++ Access 지정 / 생성자 / 소멸자 /This 포인터 (0) | 2015.06.24 |
C++ Class (0) | 2015.06.24 |
C++ 은행 계좌 관리 프로그램 (0) | 2015.06.24 |