Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include <iostream>
- #include <vector>
- #include <string>
- #include <fstream>
- #include <cmath>
- using namespace std;
- struct InventoryItem
- {
- string name;
- int weight;
- int price;
- };
- int main()
- {
- vector<InventoryItem> MyStuff;
- //Money
- InventoryItem mon;
- mon.name = "Runes";
- mon.weight = 1;
- mon.price = 1;
- //Item 1
- InventoryItem obj;
- obj.name = "flour";
- obj.weight = 100;
- obj.price = 10;
- //Item 2
- InventoryItem obj2;
- obj2.name = "wool";
- obj2.weight = 50;
- obj2.price = 20;
- //Item 3
- InventoryItem obj3;
- obj3.name = "sword";
- obj3.weight = 150;
- obj3.price = 50;
- int num;
- int del;
- int asdf;
- string name;
- MyStuff.push_back(obj); //add item 1 to inventory
- MyStuff.push_back(obj2); //add item 2 to inventory
- MyStuff.push_back(obj3); //add item 3 to inventory
- vector<InventoryItem>::const_iterator iter;
- vector<InventoryItem>::iterator myIterator;
- cout << "\t\t\t\t*Inventory Wight*\n\n";
- cout << "Your inventory, pounds and price:\n";
- asdf = 0;
- for (iter = MyStuff.begin(); iter != MyStuff.end(); ++iter)
- {
- ++asdf;
- cout << asdf << ". " << (*iter).name << " | Weight: " << (*iter).weight << " | Price: " << (*iter).price << "\n";
- }
- cout << "\nYou find a market...\n";
- market:
- cout << "what do you want to do?\n\n";
- cout << "1-look at inventory\n";
- cout << "2-look at what is for sale\n";
- cout << "3-leave\n";
- cout << "Choice: ";
- cin >> num;
- system("CLS");
- switch ( num )
- {
- case 1:
- asdf = 0;
- for (iter = MyStuff.begin(); iter != MyStuff.end(); ++iter)
- {
- ++asdf;
- cout << asdf << ". " << (*iter).name << " | Weight: " << (*iter).weight << " | Price: " << (*iter).price << "\n";
- }
- cout << "\nWhat do you want to do?\n\n";
- cout << "1-Back\n";
- cout << "2-drop an item\n";
- cout << "3-pick up and item on the ground\n";
- cout << "Choice: ";
- cin >> num;
- switch ( num )
- {
- case 1:
- system("CLS");
- goto market;
- break;
- case 2:
- cout << "\nWhat do you want to drop?\n";
- asdf = 0;
- for (iter = MyStuff.begin(); iter != MyStuff.end(); ++iter)
- {
- ++asdf;
- cout << asdf << ". " << (*iter).name << "\n";
- }
- cout << "Pick Item: ";
- cin >> num;
- MyStuff.
- break;
- case 3:
- if (0)
- {
- }
- else
- {
- }
- break;
- }
- break;
- case 2:
- cout << "hi";
- break;
- case 3:
- cout << "You walk away into the sunset.\n";
- break;
- }
- system("pause");
- return 0;
- }