Fixed and tweaked and commented the userInventory program.
This commit is contained in:
parent
94da93c4e4
commit
e1f5fe2639
1 changed files with 4 additions and 31 deletions
|
|
@ -41,32 +41,27 @@ public:
|
||||||
// cout << "Third Random Slot Num: " << thirdRandSlot << endl;
|
// cout << "Third Random Slot Num: " << thirdRandSlot << endl;
|
||||||
for(int creationIterator = 0; creationIterator < 3; creationIterator++)
|
for(int creationIterator = 0; creationIterator < 3; creationIterator++)
|
||||||
{
|
{
|
||||||
//
|
// these sequences of if statements handle the bundle substitution and such.
|
||||||
if(creationIterator == 0)
|
if(creationIterator == 0)
|
||||||
{
|
{
|
||||||
if(firstRandSlot == 1)
|
if(firstRandSlot == 1)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[0].assign("Sword");
|
inventory[0].assign("Sword");
|
||||||
}
|
}
|
||||||
if(firstRandSlot == 2)
|
if(firstRandSlot == 2)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[0].assign("Shield");
|
inventory[0].assign("Shield");
|
||||||
}
|
}
|
||||||
if(firstRandSlot == 3)
|
if(firstRandSlot == 3)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[0].assign("InvisibilityPotion");
|
inventory[0].assign("InvisibilityPotion");
|
||||||
}
|
}
|
||||||
if(firstRandSlot == 4)
|
if(firstRandSlot == 4)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[0].assign("Bread");
|
inventory[0].assign("Bread");
|
||||||
}
|
}
|
||||||
if(firstRandSlot == 5)
|
if(firstRandSlot == 5)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[0].assign("MysteryPotion");
|
inventory[0].assign("MysteryPotion");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -74,27 +69,22 @@ public:
|
||||||
{
|
{
|
||||||
if(secondRandSlot == 1)
|
if(secondRandSlot == 1)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[1].assign("Sword");
|
inventory[1].assign("Sword");
|
||||||
}
|
}
|
||||||
if(secondRandSlot == 2)
|
if(secondRandSlot == 2)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[1].assign("Shield");
|
inventory[1].assign("Shield");
|
||||||
}
|
}
|
||||||
if(secondRandSlot == 3)
|
if(secondRandSlot == 3)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[1].assign("InvisibilityPotion");
|
inventory[1].assign("InvisibilityPotion");
|
||||||
}
|
}
|
||||||
if(secondRandSlot == 4)
|
if(secondRandSlot == 4)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[1].assign("Bread");
|
inventory[1].assign("Bread");
|
||||||
}
|
}
|
||||||
if(secondRandSlot == 5)
|
if(secondRandSlot == 5)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[1].assign("MysteryPotion");
|
inventory[1].assign("MysteryPotion");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -102,27 +92,22 @@ public:
|
||||||
{
|
{
|
||||||
if(thirdRandSlot == 1)
|
if(thirdRandSlot == 1)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[2].assign("Sword");
|
inventory[2].assign("Sword");
|
||||||
}
|
}
|
||||||
if(thirdRandSlot == 2)
|
if(thirdRandSlot == 2)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[2].assign("Shield");
|
inventory[2].assign("Shield");
|
||||||
}
|
}
|
||||||
if(thirdRandSlot == 3)
|
if(thirdRandSlot == 3)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[2].assign("InvisibilityPotion");
|
inventory[2].assign("InvisibilityPotion");
|
||||||
}
|
}
|
||||||
if(thirdRandSlot == 4)
|
if(thirdRandSlot == 4)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[2].assign("Bread");
|
inventory[2].assign("Bread");
|
||||||
}
|
}
|
||||||
if(thirdRandSlot == 5)
|
if(thirdRandSlot == 5)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[2].assign("MysteryPotion");
|
inventory[2].assign("MysteryPotion");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,17 +150,14 @@ public:
|
||||||
// mutator functions
|
// mutator functions
|
||||||
void setFirstItem(string newItem)
|
void setFirstItem(string newItem)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[0].assign(newItem);
|
inventory[0].assign(newItem);
|
||||||
}
|
}
|
||||||
void setSecondItem(string newItem)
|
void setSecondItem(string newItem)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[1].assign(newItem);
|
inventory[1].assign(newItem);
|
||||||
}
|
}
|
||||||
void setThirdItem(string newItem)
|
void setThirdItem(string newItem)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
inventory[2].assign(newItem);
|
inventory[2].assign(newItem);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -215,17 +197,14 @@ int main()
|
||||||
//
|
//
|
||||||
if(subItemsAccess == 1)
|
if(subItemsAccess == 1)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
cout << "What item would you like to substitute " << currentInv.getFirstItem() << " with?" << endl;
|
cout << "What item would you like to substitute " << currentInv.getFirstItem() << " with?" << endl;
|
||||||
}
|
}
|
||||||
else if(subItemsAccess == 2)
|
else if(subItemsAccess == 2)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
cout << "What item would you like to substitute " << currentInv.getSecondItem() << " with?" << endl;
|
cout << "What item would you like to substitute " << currentInv.getSecondItem() << " with?" << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
|
||||||
cout << "What item would you like to substitute " << currentInv.getThirdItem() << " with?" << endl;
|
cout << "What item would you like to substitute " << currentInv.getThirdItem() << " with?" << endl;
|
||||||
}
|
}
|
||||||
// get the item
|
// get the item
|
||||||
|
|
@ -233,30 +212,25 @@ int main()
|
||||||
// check the item that was input.
|
// check the item that was input.
|
||||||
while(!validItemInput)
|
while(!validItemInput)
|
||||||
{
|
{
|
||||||
//
|
// validation checking for user input
|
||||||
if(tempItem == "Sword")
|
if(tempItem == "Sword")
|
||||||
{
|
{
|
||||||
//
|
|
||||||
validItemInput = true;
|
validItemInput = true;
|
||||||
}
|
}
|
||||||
else if(tempItem == "Shield")
|
else if(tempItem == "Shield")
|
||||||
{
|
{
|
||||||
//
|
|
||||||
validItemInput = true;
|
validItemInput = true;
|
||||||
}
|
}
|
||||||
else if(tempItem == "InvisibilityPotion")
|
else if(tempItem == "InvisibilityPotion")
|
||||||
{
|
{
|
||||||
//
|
|
||||||
validItemInput = true;
|
validItemInput = true;
|
||||||
}
|
}
|
||||||
else if(tempItem == "Bread")
|
else if(tempItem == "Bread")
|
||||||
{
|
{
|
||||||
//
|
|
||||||
validItemInput = true;
|
validItemInput = true;
|
||||||
}
|
}
|
||||||
else if(tempItem == "MysteryPotion")
|
else if(tempItem == "MysteryPotion")
|
||||||
{
|
{
|
||||||
//
|
|
||||||
validItemInput = true;
|
validItemInput = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -266,19 +240,17 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
validItemInput = false;
|
validItemInput = false;
|
||||||
|
// set the item once valid input from user.
|
||||||
if (subItemsAccess == 1)
|
if (subItemsAccess == 1)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
currentInv.setFirstItem(tempItem);
|
currentInv.setFirstItem(tempItem);
|
||||||
}
|
}
|
||||||
else if (subItemsAccess == 2)
|
else if (subItemsAccess == 2)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
currentInv.setSecondItem(tempItem);
|
currentInv.setSecondItem(tempItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
|
||||||
currentInv.setThirdItem(tempItem);
|
currentInv.setThirdItem(tempItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -292,6 +264,7 @@ int main()
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
// get ready for potential next bundle.
|
||||||
subItemsInput = false;
|
subItemsInput = false;
|
||||||
// push bundle to vector. (since the user is done modifying.)
|
// push bundle to vector. (since the user is done modifying.)
|
||||||
bundles.push_back(currentInv);
|
bundles.push_back(currentInv);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue