2009년 01월 23일
극장 관리 프로그램
House.h Main.cpp Seat.h Theater.h
▲ 소스 보기
#include "Theater.h"
//------------------------------------
// Theater 디폴트 생성자
//------------------------------------
Theater::Theater()
{
for(int i=0; i<7; i++)
{
House * p= new House(i+1);
h.push_back(p);
}
}
//------------------------------------
// Theater 복사 생성자
//------------------------------------
Theater::Theater(const Theater & t)
{
housenum = t.housenum;
seatnum = t.seatnum;
}
//------------------------------------
// Theater 소멸자
//------------------------------------
Theater::~Theater()
{
}
//------------------------------------
// GetKey() 함수
//------------------------------------
int Theater::GetKey()
{
int key;
key = getch();
if(key == 0)
{
key = getch();
key = key << 8;
}
return key;
}
//------------------------------------
// 메인 메뉴
//------------------------------------
int Theater::Menu()
{
system("cls");
cout << "[F1] 예약 하기 [F2] 예매 취소 [F3] 예약 현황 [ESC] 종료" << endl << endl;
cout << "※메뉴 선택 : ";
return GetKey();
}
//------------------------------------
// 메뉴 선택
//------------------------------------
void Theater::Choice()
{
int key;
while((key = Menu()) != ESC)
{
switch(key)
{
case F1: Reservation(); break; // 예약하기
case F2: Del_Reservation(); break; // 예약취소
case F3: AllList(); break; // 예약현황
case ESC: Exit(); break; // 종료
default: cout << "잘못된 선택입니다!"; getch(); break;
}
}
}
//------------------------------------
// 예약하기
//------------------------------------
void Theater::Reservation()
{
cout << " <영화 정보>" << endl;
cout << "1관 : 다크나이트" << endl;
cout << "2관 : 월-E" << endl;
cout << "3관 : 맘마미아" << endl;
cout << "4관 : 신기전" << endl;
cout << "5관 : 좋은놈, 나쁜놈, 이상한놈" << endl;
cout << "6관 : CJ7-장강7호" << endl;
cout << "7관 : 스페어" << endl << endl;
cout << "예약할 관 선택(1~7) : ";
cin >> housenum;
seatnum = h[housenum-1]->SeatChoice();
cout << "\n[예약 확인]" << endl;
cout << h[housenum-1]->GetHouse() << "관, ";
cout << seatnum << "번 좌석" << endl;
cout << "예약 완료!";
getch();
}
//------------------------------------
// 예약 취소
//------------------------------------
void Theater::Del_Reservation()
{
int del_house, del_seat;
cout << "\n예약 취소할 관 입력 : ";
cin >> del_house;
cout << "예약 취소할 좌석 입력 : ";
cin >> del_seat;
vector<House*>::iterator p;
for(p=h.begin(); p!=h.end(); ++p)
{
if((*p)->GetHouse() == del_house)
{
(*p)->Del_House(del_seat);
}
}
}
//------------------------------------
// 예약 현황 보기
//------------------------------------
void Theater::AllList()
{
vector<House*>::iterator p;
cout << "예약 현황 보기" << endl;
for(p=h.begin();p!=h.end();++p)
{
(*p)->PrintHouse();
cout<<endl;
}
cout << "출력 완료!";
getch();
}
//------------------------------------
// 프로그램 종료
//------------------------------------
void Theater::Exit()
{
cout << "사요하고 나라갑니다^^*" << endl;
GetKey();
}
//------------------------------------
// 로드
//------------------------------------
void Theater::Load()
{
ifstream file;
file.open(sjw);
if(file.is_open())
{
vector<House*>::iterator p;
for(p=h.begin(); p!=h.end(); ++p)
{
(*p)->LoadHouse(file);
}
}
else
{
cout << "▒▒▒▒▒▒▒▒▒▒▒▒▒" << endl;
cout << "▒ ▒" << endl;
cout << "▒ ◈비트 극장◈ ▒" << endl;
cout << "▒ ▒" << endl;
cout << "▒ 만든이 : 손정완 ▒" << endl;
cout << "▒ ▒" << endl;
cout << "▒ 제작일 : 2008. 8. 31 ▒" << endl;
cout << "▒ ▒" << endl;
cout << "▒▒▒▒▒▒▒▒▒▒▒▒▒" << endl << endl;
cout << "⇒처음 방문 하셨군요^^* 어서오세요~" << endl;
cout << "아무키나 누르세요! (메인으로)";
getch();
}
file.close();
}
//------------------------------------
// 세이브
//------------------------------------
void Theater::Save()
{
vector<House*>::iterator p;
ofstream file;
file.open(sjw);
for(p=h.begin(); p!=h.end(); ++p)
{
(*p)->SaveHouse(file);
}
file.close();
}
# by | 2009/01/23 14:16 | 자료구조 자료 | 트랙백











