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
|
//You are to create the following classes • Point, • AmmunitionManager
//has Ammunition, using inheritance, is a, Bullet, ShotgunShell
//• WeaponManager has Weapons, using inheritance, is a, Pistol,
//Shot Gun • Player, • Game has Player, AmmunitionManager, WeaponManager
//Each class in the Game has as one of its attributes a Point object.
//The other attributes and functions have to be determined by you.
//You are to create a dynamic array of Ammunition (the arsenal).
//You are to load the dynamic array of Ammunition with a mixture of
//bullets and shot gun shells (randomly generated).
//Once the arsenal is defined with bullets and shotgun shells you are
//to load your bullets or shot gun shells into a chamber
//(holds a fixed number of bullets) or barrel (single or double)
//into the respective weapons.
//You are to use cout’s in the constructors of each of the objects
//to output messages to the console as to what is happening in the game.
//You are to create multiple constructors for each object;
//override the default constructor and at least one other custom
//constructor
#include "iostream"
#include "bullet.h"
#include "point.h"
#include "game.h"
#include "AmmunitionManager.h"
#include "bullet.h"
#include "ShotgunShell.h"
#include "WeaponManager.h"
#include "Shotgun.h"
#include "Pistol.h"
using namespace std;
void InitialiseArray( int *, int); //As arrays are pointers I can pass an array as a pointer
void DisplayArray( int [], int); //Passing an array, array syntax
int main()
{
const int ciSize = 10;
int ArsenalArray[ciSize]; //One dimensional array
int Arsenal[ciSize] = {2,7,12,-5,9,10};
DisplayArray( Arsenal, ciSize);
cout << endl << endl;
InitialiseArray( ArsenalArray, ciSize);
DisplayArray( ArsenalArray, ciSize);
cout << endl << endl;
//Pistol pistol1;
//pistol1.setpgColour();
//WeaponManager Shotgun;
//Shotgun.setmiWeapons(23);
//WeaponManager weapon1;
//weapon1.setmiWeapons(100);
//Bullet theBullet; //object of bullet
//Bullet theBullet2(23,24);
//Game theGame;
//Game theGame2(45,23);
//Point thePoint;
//ShotgunShell shot1;
//theBullet.setDamage(23);
//Bullet theBullet2(3,4);
//theBullet.setX(10);
//theBullet.setY(24);
// Ammunition theAmmunition;
// Ammunition theAmmunition2(1,2);
//theAmmunition.setA(45);
//theAmmunition.setB(15);
//Bullet ihBullet;
//Bullet ihBullet2;
//ihBullet.setA(23);
//ihBullet2.setB(0);
system("pause");
}
void InitialiseArray( int *aNumbers, int iS )
{
for( int i=0; i < iS; i++ )
{
aNumbers[i] = -1;
}
}
void DisplayArray( int aNumbers[], int iS )
{
for( int i=0; i < iS; i++ )
{
cout << aNumbers[i] << " ";
}
}
|