Create a program which will create a Hero's Inventory. The program should take the user input (a number) and put that item into the inventory (for example, if the user enters 1. Sword, the program should insert the string "Sword" into the inventory). You will need to add a loop that allows the user to keep adding items into the inventory until it reaches a maximum number of list items, or the user decides to terminate adding.You will need two menus, one with items the user can add to their inventory, and another menu which lists actions they can take 1-Add Item, 2-Delete Item, 3-Swap Item.
Everytime there is a change to the inventory, either an item is added, deleted, or swapped, the new inventory should print. This inventory should be housed in a single-dimensional string array.
____________________________________________________________________________

#include <iostream>
#include <string>

using namespace std;

int main()
{
   
   unsigned int x=100; //health
    const int MAX_ITEMS = 10;
    const int MAX_ITEMS2 =5;
    string inventory[MAX_ITEMS];
    string inventory2 [MAX_ITEMS2];
    int numItems = 0;
    int choice=numItems;
  int numItems2=0;
  char another;

  

 // begin loop
  do
{
    // list of items for input
   
inventory[0] = "sword";
inventory[1] = "armor";
inventory[2] = "shield";
inventory[3] = "knife";
inventory[4] = "gun";
inventory[5] = "axe";
inventory[6] = "hammer";
inventory[7] = "belt";
inventory[8] = "boots";
inventory[9] = "hat";

// list of items for user to pick/see
cout<< "welcome to RPG inventory\n";
cout<<"1. sword\n";
cout<<"2. armor\n";
cout<<"3. shield\n";
cout<<"4. knife\n";
cout<<"5. gun\n";
cout<<"6. axe\n";
cout<<"7. hammer\n";
cout<<"8. belt\n";
cout<<"9. boots\n";
cout<<"10. hat\n\n\n";


// inventory choice and health choice
cout<< "please pick a item to add to your inventory\n";
cout<< "health will drop 10 points for every item\n\n";  
    
   cin>> choice;
  inventory2[numItems2]=inventory[choice-1];
numItems2++;
    cout << "Your items:\n";      
   if (numItems2 < MAX_ITEMS2)
   {
    
    for (int i = 0; i < numItems2; ++i)
    
    
    cout << inventory2[i] << endl;
    
    
    cout << inventory2[numItems2] << endl;
    
    cout<< "your health is now\n";
          x = x - 10; cout << x;
          
          
   }// end if
   else 
   
        
   cout << "You have too many items and can't carry another.";  

// end else


//ending part of loop
  cout << "\n\n\nWould You Like To Play Again? (y/n): ";
cin >> another;

 }while(another == 'Y' || another == 'y') ;// loop
 


 return 0;
}//end main

she wants it to do whats in the description

You haven't actually presented us with a problem. You have said it should do this, and not actually pointed out where you are stuck...we don't do it for you we aid you. We are not going to write entire sections of code for you.

Have an attempt to make it do what you asked, if you get stuck then post and tell us what the problem is.

Thanks,
Chris

This article has been dead for over six months. Start a new discussion instead.