void Store::Sell(Player & player, int type) {
Item * mPoint;
int select=0;
string cat="Default";
if(type == 1) {
cat = "Weapon";
mPoint = player.getWeapon();
}
if(type == 2) {
cat = "Armour";
mPoint = player.getArmor();
}
else if(type == 3) {
cat = "Item";
mPoint = player.getItem();
}
switch ( type ) {
case 1:
cout <<"\n\t\t" << cat << ": \t\t" << mPoint->GetName() << "\n";
cout << "\t\tValue is: \t\t" << mPoint->GetValue() << "\n";
cout << "\t\tDamage Range: \t\t0\n";
break;
case 2:
cout <<"\n\t\t" << cat << ": \t\t" << mPoint->GetName() << "\n";
cout << "\t\tValue is: \t\t" << mPoint->GetValue() << "\n";
cout << "\t\tDamage Protection: \t\t0\n";
break;
case 3:
cout <<"\n\t\t" << cat << ": \t\t" << mPoint->GetName() << "\n";
cout << "\t\tValue is: \t" << mPoint->GetValue() << "\n";
cout << "\t\tQuantity is: \t" << mPoint->GetQty() << "\n";
cout << "\t\tDesc: \t\t" << mPoint->GetDesc() << "\n";
break;
}
working with array and pointers
sorry about triple posting, i had really bad probelms with connection kept coming up with server error :s, so unsure whether i was, sincerly sorry.
erm the question was supposed to be, im unsure how to change the pointer to point to the next element in array, im not sure how to initiaze it to be more precise, i originally thought you can increment it by pointer++, and so on, but leads me to think my code is wrong somewhere along the line, so thought best place to find out is here :D!
I have set up two Item objects in Player class constructor and when the gets into case 3 in Store::Sell ,want it to be able to go one by one through them, i realise i need array which *hopefully* implemented just need to be able to do it?! i tried the mPoint++ but to no avail
snippet from Player declaration:
Item * mItem;
..also the player constructor
mItem = new cItem[];
cItem("Potion",5, 10, "Healing Tonic");
cItem("Ether", 3, 40, "Partially restores MagicPoints");
[Edited by - dcuk on September 23, 2005 1:37:15 PM]
Careful about that triple posting - I've cleaned it up for you though. [wink]
Now, you might want to actually ask a question. I'm assuming you have a problem with that source code that you'd like some help with? Tell us what the problem is, and what error messages you got, someone might be able to help.
Now, you might want to actually ask a question. I'm assuming you have a problem with that source code that you'd like some help with? Tell us what the problem is, and what error messages you got, someone might be able to help.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement