diff --git a/assignmentTwo/librarybook b/assignmentTwo/librarybook index dd8c50b..c963a4b 100755 Binary files a/assignmentTwo/librarybook and b/assignmentTwo/librarybook differ diff --git a/assignmentTwo/userInventory b/assignmentTwo/userInventory new file mode 100755 index 0000000..671c048 Binary files /dev/null and b/assignmentTwo/userInventory differ diff --git a/assignmentTwo/userInventory.cpp b/assignmentTwo/userInventory.cpp index e69de29..9f14280 100644 --- a/assignmentTwo/userInventory.cpp +++ b/assignmentTwo/userInventory.cpp @@ -0,0 +1,314 @@ +/* +Program Name: User Inventory +Process: ??? +Function Input/Parameters: ??? +Function Output/Parameters: ??? +Function Output/Returned: ??? +Device Input/Device: ??? +Device Output/Monitor: ??? +Dependencies: ??? +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +// class definitions +class UserInventory +{ +private: + vector inventory; + static int bundleCount; +public: + UserInventory() + { + bundleCount = bundleCount + 1; + // default constructor + inventory.resize(3); + // get a random value between 1 & 5 using standard C method. (outdated, I know...) + int firstRandSlot = rand() % (5 - 1) + 1; + // cout << "First Random Slot Num: " << firstRandSlot << endl; + int secondRandSlot = rand() % (5 - 1) + 1; + // cout << "Second Random Slot Num: " << secondRandSlot << endl; + int thirdRandSlot = rand() % (5 - 1) + 1; + // cout << "Third Random Slot Num: " << thirdRandSlot << endl; + for(int creationIterator = 0; creationIterator < 3; creationIterator++) + { + // + 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"); + } + } + if(creationIterator == 1) + { + 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"); + } + } + if(creationIterator == 2) + { + 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"); + } + } + } + } + ~UserInventory() + { + // default destructor + } + // accessor functions + string getFirstItem() + { + // ask the vector for the first item. + return inventory[0]; + } + string getSecondItem() + { + // ask the vector for the second item. + return inventory[1]; + } + string getThirdItem() + { + // ask the vector for the third item. + return inventory[2]; + } + static int getBundleCount() + { + return bundleCount; + } + void getUserInventory() + { + // ask the vector for all three items + // output the items to screen. + cout << "Your Bundle Selection:" << endl; + cout << "\tItem 1: " << getFirstItem() << endl; + cout << "\tItem 2: " << getSecondItem() << endl; + cout << "\tItem 3: " << getThirdItem() << endl; + cout << endl; + } + // 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); + } +}; +int UserInventory::bundleCount = 0; + +// function definitions + +// main function +int main() +{ + bool bundlesInput = false; + bool subItemsInput = false; + bool validItemInput = false; + char bundlesInputChar; + char subItemsInputChar; + int subItemsAccess = 0; + string tempItem; + vector bundles; + // get a C style number generator seeded. + srand(time(NULL)); + // big main loop for entering in bundles + while(!bundlesInput) + { + // + // call the userInventory class + UserInventory currentInv; + // show the user the inventory generated. + currentInv.getUserInventory(); + cout << "You can now make substitutions for the inventory." << endl; + while(!subItemsInput) + { + cout << "Please enter which item (1-3) you would like to substitute." << endl; + cin >> subItemsAccess; + cin.ignore(); + if(subItemsAccess == 1 || subItemsAccess == 2 || subItemsAccess == 3) + { + // + 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 + getline(cin, tempItem); + // check the item that was input. + while(!validItemInput) + { + // + 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 + { + // let the user know they did not input a valid value. + cout << "Please enter a valid value." << endl; + } + } + validItemInput = false; + if (subItemsAccess == 1) + { + // + currentInv.setFirstItem(tempItem); + } + else if (subItemsAccess == 2) + { + // + currentInv.setSecondItem(tempItem); + } + else + { + // + currentInv.setThirdItem(tempItem); + } + } + // ask user if they are done substituting + cout << "Finished substituting?: " << endl; + cin >> subItemsInputChar; + cin.ignore(); + if (subItemsInputChar == 'y' || subItemsInputChar == 'Y') + { + subItemsInput = true; + } + cout << endl; + } + subItemsInput = false; + // push bundle to vector. (since the user is done modifying.) + bundles.push_back(currentInv); + // show the bundle. + cout << "Completed Bundle: " << endl; + currentInv.getUserInventory(); + // ask the user if they are done entering bundles. + cout << "Done entering bundles?: " << endl; + cin >> bundlesInputChar; + cin.ignore(); + if (bundlesInputChar == 'y' || bundlesInputChar == 'Y') + { + bundlesInput = true; + } + cout << endl; + cout << "Number of bundle objects: " << UserInventory::getBundleCount() << endl; + } + // code here. + return 0; +}