Fixed and tweaked and commented the userInventory program.

This commit is contained in:
Charles Descamps 2024-09-23 15:54:01 -07:00
parent 94da93c4e4
commit e1f5fe2639

View file

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