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
|
#include <iostream>
#include <string>
using namespace std;
enum weapVarNames{WEAPON_NAME = 1, WEAPON_AMMO_TYPE = 2, WEAPON_DAMAGE_DEALT = 3, WEAPON_COST = 4, ALL_INFO = 5};
class Weapon
{
public:
Weapon(const string m_weaponName, const string m_weaponAmmoType,
const float m_weaponDamageDealt, const float m_weaponCost): weaponName(m_weaponName),
weaponAmmoType(m_weaponAmmoType),
weaponDamageDealt(m_weaponDamageDealt),
weaponCost(m_weaponCost){}
void DisplayWeaponInfo(Weapon& weapon, int select);
~Weapon();
private:
const string weaponName;
const string weaponAmmoType;
const float weaponDamageDealt;
const float weaponCost;
};
Weapon::~Weapon()
{
}
void Weapon::DisplayWeaponInfo(Weapon& weapon, int select)
{
switch(select)
{
case WEAPON_NAME:
cout << weaponName << endl;
break;
case WEAPON_AMMO_TYPE:
cout << weaponName << " Ammo Type: " << weaponAmmoType << endl;
break;
case WEAPON_COST:
cout << weaponName << " Cost: $" << weaponCost << endl;
break;
case WEAPON_DAMAGE_DEALT:
cout << weaponName << " Damage: " << weaponDamageDealt << endl;
break;
case ALL_INFO:
cout << weaponName << endl;
cout << weaponName << " Ammo Type: " << weaponAmmoType << endl;
cout << weaponName << " Cost: $" << weaponCost << endl;
cout << weaponName << " Damage: " << weaponDamageDealt << endl;
break;
default:
cout << "Could not display requested information" << endl;
}
}
int main()
{
Weapon handgun("Handgun", "9mm", 5.0, 300.0);
handgun.DisplayWeaponInfo(handgun, WEAPON_DAMAGE_DEALT);
cout << "\n";
Weapon rifle("Rifle", "5.56mm", 10, 600);
rifle.DisplayWeaponInfo(rifle, WEAPON_DAMAGE_DEALT);
return 0;
}
|