How to compare a vector to a map

Okay so I have an `inventory` class that accesses a static vector from my base class `MainShop`. I also have a `SwordShop` class which inherits from `MainShop`. (Both Inventory and SwordShop are derived classes).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//SwordShop class
    void SwordShop::Shop
    {
    //I have a setter function where it takes an integer and a string and adds its 
//to my hashmap.
    //Also have a getter function which has a for loop displaying my items in my map
    this->setWeaponSoldier(1, "1) Meito Ichimonji\n   +4 Damage\n   150Gold");
    this->setWeaponSoldier(2, "2) Shusui\n   +10 Damage\n   230Gold");
    this->setWeaponSoldier(3, "3) Elixir\n   +16 Damage\n   300Gold");
    this->setWeaponSoldier(4, "4) Blade of scars\n   +24 Damage\n   550Gold");
    this->setWeaponSoldier(5, "5) Ragnarok\n   +32 Damage\n   610Gold");
    this->setWeaponSoldier(6, "6) Eternal Darkness\n   +40 Damage\n   690Gold");
    this->setWeaponSoldier(7, "7) Masamune\n   +52 Damage\n   750Gold");
    this->setWeaponSoldier(8, "8) Soul Calibur\n   +60 Damage\n   900Gold");
    
    }

    //Function in my inventory class
    void Inventory::DisplayInventory()
    {
        int choice;
    	cout << "\nWhat do you want to do?\n1) Check Status\n2) Equip Weapons\n";
//Equip what is in your inventory
    	cin >> choice;
    	switch (choice)
    	{
            case 1: this->DisplayStats();
                break;
            case 2:cout << WeaponInventory.size() << endl;//debug
                if (!WeaponInventory.empty())//Make sure inventory is not empty
                {
                    cout << "Your current Weapons are: \n";
                    for (unsigned int i = 0; i < WeaponInventory.size(); ++i)
                        cout << i+1 << ") " << WeaponInventory[i] << endl;
//cout whats currently in my inventory
                    cout << "What item weapon would you like to equip?";
    				/***********Here is the problem*******************/
    				//how can I make the user choose the actual
 and correct item in the inventory?
                    //cin >> equipChoice;
                    //code goes here
                }
                else cout << "Error! You currently do not own any items\n";
                break;
      }

So for example lets say the user adds `Meito Ichimonji` into my `WeaponInventory` vector and then adds another one. How can I make the user have the ability to pick the right item? Im looking for something like this:



1
2
3
4
5
6
7
8
9
10
11
12
13
14
  //PseudoCode
    Displays my inventory with for loop
    I have two items in it which user buys
    1)Meito Ichimonji
    and 
    2)Elixir
    cout << "what would you like to equip?";
    cin >> equipChoice
    if (equipChoice == 1)//chooses whatever item is first
    check to see what the attack that the weapon has and add it to my attack
    attack += 20;//lets say the sword had 20 attack
    else if (equipChoice == 2)//chooses whatever is second
    do something else
    etc...


Sorry if I have not explained it clearly, but I tried my best!
Topic archived. No new replies allowed.