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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
#include <iostream>
using namespace std;
//global variables
int MONEY = 1000; //initial money
int MEDKIT = 0, LIGHTER =0, KNIFE =0, FOOD =0, WEAPON =0, CLOTHING =0, ROPE =0, TENT =0, COMPASS =0;//items amounts
class store
{
public:
string name;
string desc; //decription
int price;
void stat(int price, int item); // display item information
void amount(int price, int item);
void storeMenu(int item); //display menu of items and options
void inventory();
store();
~store();
}medkit, lighter, knife, food, weapon, clothing, rope, tent, compass, menu;
store::store()//constructor
{
}
store::~store()//destructor
{
}
void store::stat(int price, int item)
{
cout << "**********" <<endl;
cout << "Name: \t" << name <<endl;
cout << "Price \t$" << price <<endl;
cout << "Description: " << desc <<endl;
cout << "**********" <<endl <<endl;
amount(price, item);
}
void store::amount(int price, int item)
{
cout << "How many would you like to purchase?"<<endl;
int amt;
cin >> amt;
if(MONEY < (price * amt))//not enough money, will * choiceamount and value before comparing with money
{
cout << endl <<endl;
cout << "**********You do not have enough money!**********"<<endl<<endl;
storeMenu(item);
}
else
{
MONEY -= (price * amt);
item += amt;//store amount and put into variable for future inventory
storeMenu(item);
}
}
void store::storeMenu(int item)
{
char choice;//needs to be char for choices cuz of '1'
//display money amount
cout << "**************" <<endl;
cout << " Money $" << MONEY <<endl;
cout << "**************" <<endl <<endl;
cout << "Choose which supply you would like to purchase" << endl;
cout << "E) ***Exit Menu***" <<endl<<endl;
cout << "1) Medkit" << endl;
cout << "2) Lighter" << endl;
cout << "3) Knife" << endl;
cout << "4) Food" <<endl;
cout << "5) Weapons" << endl;
cout << "6) Clothing" << endl;
cout << "7) Rope" << endl;
cout << "8) Tent" <<endl;
cout << "9) Compass" << endl<<endl;
cin >> choice;
if(choice == '1')//choice for items
medkit.stat(price = 100, MEDKIT += item);
if(choice == '2')
lighter.stat(price = 50, LIGHTER += item);
if(choice == '3')
knife.stat(price = 100, KNIFE += item);
if(choice == '4')
food.stat(price = 150, FOOD += item);
if(choice == '5')
weapon.stat(price = 150, WEAPON += item);
if(choice == '6')
clothing.stat(price = 50, CLOTHING += item);
if(choice == '7')
rope.stat(price = 25, ROPE += item);
if(choice == '8')
tent.stat(price = 300, TENT += item);
if(choice == '9')
compass.stat(price = 50, COMPASS += item);
if(choice == 'e' ||choice == 'E')
{
inventory();
}//end of choice exit
}//end store function
void store::inventory()
{
cout << "****INVENTORY****"<<endl;
cout << "Money $" <<"\t\t"<< MONEY <<endl;
cout << "Medkits: " <<"\t"<< MEDKIT <<endl;
cout << "Lighters: "<<"\t" << LIGHTER <<endl;
cout << "Knives: "<<"\t" << KNIFE <<endl;
cout << "Food: "<<"\t\t" << FOOD <<endl;
cout << "Weapons: "<<"\t" << WEAPON <<endl;
cout << "Clothing: "<<"\t" << CLOTHING <<endl;
cout << "Rope: "<<"\t\t" << ROPE <<endl;
cout << "Tent: "<<"\t\t" << TENT <<endl;
cout << "Compass: "<<"\t" << COMPASS <<endl<<endl;
}//end inventory()
int main(int item)
{
medkit.name = "Medical Kit";
medkit.price = 100;
medkit.desc = "A medkit will heal your party's wounds. ";
lighter.name = "Lighter";
lighter.price = 50;
lighter.desc = "A lighter will provide you with fire. ";
knife.name = "Knife";
knife.price = 100;
knife.desc = "A knife will provide you will a valuable tool as well as a weapon. ";
food.name = "Food";
food.price = 150;
food.desc = "Food is essential to surviving. ";
weapon.name = "Weapon";
weapon.price = 150;
weapon.desc = "A weapon will provide you with strong protection. ";
clothing.name = "Clothing";
clothing.price = 50;
clothing.desc = "Clothing will provide you protection from the weather. ";
rope.name = "Rope";
rope.price = 25;
rope.desc = "Rope will provide you the ability to craft in the wilderness. ";
tent.name = "Tent";
tent.price = 300;
tent.desc = "A tent will provide your party with shelter. ";
compass.name = "Compass";
compass.price = 50;
compass.desc = "A compass will provide you with navigation. ";
menu.storeMenu(item);
}//end main
|