53 lines
946 B
C++
53 lines
946 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
class Game
|
|
{
|
|
public:
|
|
Game(){}
|
|
virtual ~Game(){}
|
|
virtual void initialize() = 0;
|
|
virtual void startPlay() = 0;
|
|
virtual void endPlay() = 0;
|
|
virtual void play() final
|
|
{
|
|
initialize();
|
|
startPlay();
|
|
endPlay();
|
|
}
|
|
};
|
|
|
|
class Cricket : public Game
|
|
{
|
|
public:
|
|
void initialize()
|
|
{
|
|
cout << "Cricket Game Initialized Start playing" << endl;
|
|
}
|
|
void startPlay()
|
|
{
|
|
cout << "Cricket Game Started Enjoy the game" << endl;
|
|
}
|
|
void endPlay()
|
|
{
|
|
cout << "Cricket Game Finished" << endl;
|
|
}
|
|
};
|
|
|
|
class Football : public Game
|
|
{
|
|
public:
|
|
void initialize()
|
|
{
|
|
cout << "Football Game Initialized Start playing" << endl;
|
|
}
|
|
void startPlay()
|
|
{
|
|
cout << "Football Game Started Enjoy the game" << endl;
|
|
}
|
|
void endPlay()
|
|
{
|
|
cout << "Football Game Finished" << endl;
|
|
}
|
|
};
|