Well For my fundamentals of programming we have to do a
Fantasy RPG invetory FlowChart,Pseudocode and Code
I got stuck with code...
We got a source code and customized it a lil
problem is we are tryin to make a choice within a choice
// Hero's Inventory
// Demonstrates arrays
// By rainbow78 at daniweb
//http://www.daniweb.com/forums/thread84020.html
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<ctime>
usingnamespace std;
constint MAX_ITEMS = 12;
constint MAX_ITEMS2 = 5;
int main()
{
unsignedint health = 200; //health
unsignedint mana = 100; //mana
string inventory[MAX_ITEMS];
string inventory2 [MAX_ITEMS2];
int numItems = 0; //always assign a value to new variables
int choice=numItems;
int numItems2=0;
char another;
cout << "Player is wearing Basic armor(Full leather armor,knife & Shield)." << endl;
// begin loop
do
{
// list of items for input
// Array list
inventory[0] = "Stamina";
inventory[1] = "Mana";
inventory[2] = "Eguipment";
inventory[3] = "Melee";
inventory[4] = "Range";
inventory[5] = "Support Spells";
inventory[6] = "Offensive Spells";
// list of items for user to pick/see
cout<< "\n\n";
cout<< "welcome to Fantsy RPG inventory!\n";
cout<<"1. Stamina\n";
cout<<"2. Mana\n";
cout<<"3. Eguipment\n";
cout<<"4. Melee\n";
cout<<"5. Range\n";
cout<<"6. Support Spells\n";
cout<<"7. Offensive Spells\n";
// inventory choice and health choice
cout<< "\n\n";
cout<< "please pick a item to add to your inventory\n";
cout<< "Regenerate +10 Stamina when remained on pause once.\n\n";
cin >> choice;
inventory2[numItems2]=inventory[choice-1];
numItems2++;
cout << "Your items:\n";
if (numItems2 < MAX_ITEMS2)
{
for (int i = 0; i < numItems2; ++i)
cout << inventory2[i] << endl;
cout << inventory2[numItems2] << endl;
}// end if
else
cout << "You have too many items and can't carry another."; // When Max is reached Output will show
// end else
// switch stament
switch(choice)
{
case 1:
health++; // Health
cout << health << endl; //test
break;
case 2:
mana++; // Mana
cout << mana << endl; //test
break;
case 3: // Eguipment
cout<< " Plate Mail" << endl;
cout<< " Mithril Armor" << endl;
cout<< " Bronze Armor" << endl;
break;
case 4: // Melee
cout<< " Axe" << endl;
cout<< " Club" << endl;
cout<< " Broad sword" << endl;
break;
case 5: // Range
cout<< " CrossBow" << endl;
cout<< " Ballista" << endl;
cout<< " Throwing Knifes" << endl;
cout<< " Throwing Spear" << endl;
break;
case 6: // Support Spells
cout<< " Heal Scroll" << endl;
cout<< " Shield Scroll" << endl;
cout<< " Haste Scroll" << endl;
break;
case 7: // Offensive Spells
cout<< " Fire Bolt scroll" << endl;
cout<< " Ice Bolt scroll" << endl;
cout<< " Lightning Bolt scroll" << endl;
break;
default: cout << "thats not a choice idiot!";
}
//ending part of loop
cout << "\n\n\nWould You Like To Play Again? (y/n): ";
cin >> another;
}while(another == 'Y' || another == 'y') ;// loop
return 0;
}//end main
So when we run it on Visual studio and we got it running
I added the switch statement but when we debug it we wanna make it so you choose one of the weapons or eguipment
and itll show that you eguipped it
so at the end itll show all the eguipment you have eguipped
Any ideas on how to do...
I tried adding a If stament but didnt work
Please and Thank you.
This is more or less C programming style.
I suggest you to use C++ style rather than C style.
Use Object-Oriented concepts to eliminate that long switch statement.