#include <iostream> #include <stack> #include <string> using namespace std;
enum MENU { MENU_MAIN, MENU_GRAPHIC, MENU_SOUND, MENU_GAME, MENU_GAMMA, MENU_RESOLUTION,
MENU_END, };
class CMenu { public: virtual ~CMenu() { cout << "메뉴" << endl; };
virtual void Display() { cout << "메인 매뉴입니다. 명령 : 그래픽 사운드 게임설정\n"; }
virtual MENU Progress(string& command) { if (command == "그래픽") return MENU_GRAPHIC; if (command == "사운드") return MENU_SOUND; return MENU_END; } };
class CGraphicMenu : public CMenu { public: virtual ~CGraphicMenu() { cout << "그래픽" << endl; } virtual void Display() { cout << "출력 매뉴 입니다. 명령 : 감마 해상도 퀼리티\n"; }
virtual MENU Progress(string& command) { if (command == "감마") return MENU_GAMMA; if (command == "해상도") return MENU_SOUND; return MENU_END; } }; class CGammacMenu : public CMenu { public:
virtual ~CGammacMenu() { cout << "감마" << endl;; }
virtual void Display() { cout << "감마 매뉴 입니다. 명령 : 없어 그런거\n"; }
virtual MENU Progress(string& command) {
return MENU_END; } };
void Test() { CMenu menu1; CGraphicMenu menu2; CGammacMenu menu3;
CMenu* menus[MENU_END]{}; menus[MENU_MAIN] = &menu1; menus[MENU_GRAPHIC] = &menu2; menus[MENU_GAMMA] = &menu3;
stack<CMenu*> menuStack; menuStack.push(menus[MENU_MAIN]);
while (!menuStack.empty()) { CMenu* top = menuStack.top(); top->Display(); string ss; cin >> ss; MENU result = top->Progress(ss);
if (result == MENU_END) menuStack.pop(); else if (menus[result]) menuStack.push(menus[result]); }
cout << "이용해주셔서 고맙다\n"; }
int main() { Test();
}
|