1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#include "stdafx.h"
#include <iostream>
using namespace std;
class Character {
protected:
int x,y; // co-ordinate positions
char* name;
char* characterType;
public:
Character(int start_x,int start_y,char* n) {
x=start_x;
y=start_y;
name=n;
characterType=new char[2];
}
virtual ~Character() {
delete name;
delete characterType;
}
virtual void print() {
cout << "\n" << name << " " << characterType << " " << x << " " << y;
}
};
class Protagonist : public Character {
protected:
char* weapon;
public:
Protagonist(int start_x,int start_y,char* name,char* w) : Character(start_x,start_y,name) {
weapon=w;
characterType="Protagonist";
}
~Protagonist() {
delete weapon;
}
void print() {
Character::print(); //call the base class function
cout << " Weapon: " << weapon;
}
};
class Enemy : public Character {
protected:
char* weapon;
public:
Enemy(int start_x,int start_y,char* name,char* w) : Character(start_x,start_y,name) {
weapon=w;
characterType="Enemy";
}
~Enemy(){
delete weapon;
}
void print() {
Character::print(); //call the base class function
cout << " Weapon: " << weapon;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
cout << " Metal Gear Solid\n";
Character* cList[11];
cList[0]=new Protagonist(0,0,"Solid Snake","SOCOM");
cList[1]=new Enemy(1,2,"Liquid Snake","USP");
cList[2]=new Enemy(1,3,"Solidus Snake","P90");
cList[3]=new Enemy(1,4,"Revolver Ocelot","Single Action Army");
cList[4]=new Enemy(1,5,"Cyborg Ninja","Sword");
cList[5]=new Enemy(1,6,"Sniper Wolf","PSG1");
cList[6]=new Enemy(1,7,"Vamp","Knives");
cList[7]=new Enemy(1,8,"Fatman","Glock");
cList[8]=new Enemy(1,9,"Fortune","Rail Gun");
cList[9]=new Enemy(1,10,"Vulcan Raven","Mini Gun");
cList[10]=new Enemy(2,5,"The Pain","Bees");
// print them out
for(int i=0;i<11;i++) {
cList[i]->print();
}
// to stop exiting until we've read the screen
int y;
cin >> y;
return 0;
}
|