CPP 게임 실습

실습과제 모음 2012. 9. 22. 14:50 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

CPP 게임 실습

#include <iostream>

using namespace std;

class Game

{  

public:

    virtual void start(){};

};

class BaseBall : public Game

{

public:

    void start(){

        cout << "BaseBall Start!!" << endl;

    };

};

class UpDown : public Game

{

public:

    void start(){

        cout << "UpDown Start!!" << endl;

    };

};

void main()

{

    Game* game[2];

    BaseBall baseball;

    UpDown updown;

    game[0] = &baseball;

    game[1] = &updown;

    int mode;

    cout << "====================" << endl;

    cout << "=1. BaseBall =======" << endl;

    cout << "====================" << endl;

    cout << "=2. UpDown==========" << endl;

    cout << "====================" << endl;

    cout << "input:" ;

    cin >> mode;

    system("cls");

    if( mode == 1 )

    {

        cout << "====================" << endl;

        cout << "=1. BaseBall =======" << endl;

        cout << "====================" << endl;

        game[0]->start();

    }

    else if( mode == 2 )

    {

        cout << "====================" << endl;

        cout << "=2. UpDown==========" << endl;

        cout << "====================" << endl;

        game[1]->start();

    }

}

 

'실습과제 모음' 카테고리의 다른 글

[JAVA1] 2012-10-14 실습 #1  (0) 2012.10.14
CPP 실습  (0) 2012.09.22
C언어 실습문제 0811  (0) 2012.08.11
JAVA Mysql + JTable + File  (0) 2012.07.29
JAVA JFrame + MySql 추가 실습예제  (0) 2012.07.28