pendo826 0 Light Poster

Hi need some help. I dont really know much about classes and objects and i dont understand tutorials and i want to make it that when a user picks up objects it will be added to an inventory that i have set up and also when the inentory is full i can drop items. I dont understand hwo to do this can anyone help me please

#include <iostream>
#include <string> // To allow use of Strings.
using namespace std;



//char inventoryRequest = 'i';
//Function Definitions.
void displayInventory();
void displayStats();
void stats();
void inventory();
void exitGame();
int playGame();
int main()
{
//Menu Text.
cout<< "\t******Menu******\n\n";
cout<< "Please choose one of the following:\n";
cout<< "1 -Play Game.\n";
cout<< "2 -Exit.\n";


int choice;
cout<< "Choice: ";
cin>> choice;
string name;
switch (choice)
{
//Menu 1 choice.
case 1:
playGame();
break;
//Menu 1 choice.
case 2:
exitGame();
break;
default:
cout<< "That is not a choice!!!\n";
}


getchar();
getchar();
return 0;
}

//Method for play game.
int playGame()
{
string name;
int age;
char sex;
cout<< "What is your name?\n";
cin>> name;
cout<< "What is your age?\n";
cin>> age;
cout<< "What is your sex, M or F?\n";
cin>> sex;
cout <<"Name:"<< name<<" Age:" << age<< " Sex:"<< sex <<"\n";
cout << "To view your Inventory press i.";
inventory();
cout << "To view your Inventory press s.";
stats();
//Introduction to the Storyline.
cout <<"You are a Roman Soldier in the small town of Udinse.  There has been rumours that the Viking are coming to find and kill the heir to Julias Ceaser in order"
	   "to unsettle the roman soldiers invading scandinavia the Viking territory.  All Roman Solidiers are filled with anxiety and are ordered by there supieriors to keep watch on these treachorous nights."
	   "It is also rumoured that the heir to the throne Maxis Aurilias Ceaser has been hidden in a small Roman town to keep him under the radar from the Vikings."
	   "Even the Soldiers don't know the wherabouts of the heir.  Everyone is nervous and fearful of an immediate Viking attack."
       "It is a cold and windy night on the top of the watch tower keeping a lookout for unusual activity.  your armour soaked and heavy.  Nearly time to finish your shift and go home to bed."
       "You walk around the last corner to your house when you see Viking Soldiers raiding house to house.  You are unseen and run to the tower to alert the soldiers. The battle goes on for a few hours, the Roman Soldiers being killed off like rats."
	   "After standing your ground in a gruesome fight you are surrounded and ready to die.  Such a young life,  Only 21.  Memories began to flooed through your head like a rapid. The moment of truth.  The Viking edges towards you raises his blood stained sword and"
	   ".....................";
//Storyline.
cout << "\n\nYou awake, grogey form being struck in the head, tired from the fight the previous night.";
return 0;
}

void exitGame()
{
	cout << "Please press enter to exit the game.";
}




void inventory()
{
	char input[80];
	cin >> input;
	char inventoryRequest[] = "i";
	int invent = strcmp (input,inventoryRequest);
	//compare the player input to inventaryRequest (i) to see if they want to look at inventarty
	if(invent == 0)
	{
	displayInventory();
	}

}

    void displayInventory()
	{
    const int SIZE = 11;
    string inventory[SIZE];
	cout << "******Inventory******\n";
	inventory[0] = "Rock\n";
    inventory[1] = "Stick\n";
	inventory[2] = "Empty\n";
	inventory[3] = "Empty\n";
	inventory[4] = "Empty\n";
	inventory[5] = "Empty\n";
	inventory[6] = "Empty\n";
	inventory[7] = "Empty\n";
	inventory[8] = "Empty\n";
	inventory[9] = "Empty\n";
	inventory[10] = "To continue press Enter.\n";
	cout << "\n" <<endl;
    for (int i = 0; i < SIZE; ++i) {
	
    cout << inventory[i];
	}
    getchar();
	getchar();
	}
	
	
	void stats()
{
	char input[80];
	cin >> input;
	char statsRequest[] = "s";
	int stats = strcmp (input,statsRequest);
	//compare the player input to statsRequest (i) to see if they want to look at inventory
	if(stats == 0)
	{
	displayStats();
	}

}

    void displayStats()
	{
    const int SIZE = 11;
    string stats[SIZE];
	cout << "******Stats******\n";
	stats[0] = "Health\n";
    stats[1] = "\n";
	stats[2] = "Empty\n";
	stats[3] = "Empty\n";
	stats[4] = "Empty\n";
	stats[5] = "Empty\n";
	stats[6] = "Empty\n";
	stats[7] = "Empty\n";
	stats[8] = "Empty\n";
	stats[9] = "Empty\n";
	stats[10] = "To continue press Enter.\n";
	cout << "\n" <<endl;
    for (int s = 0; s < SIZE; ++s) {
	
    cout << stats[s];
    }
    getchar();
	getchar();
	}

	void inventoryObject()
	{
    class inventory {
	public://Access Specifier.
    float weight; // Attributes.

	int add();// Actions.
	int drop ();// Actions.
	};
   
	inventory Inventory = {50};



	}

	void statsObject()
	{
		class status{
		public:
			float health;
			float strength;




		};

		status Status = {100, 50};


	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.