60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
/*
|
|
Program Name: Inventory
|
|
Process: Write a program that dynamically manages an inventory system for a roleplaying
|
|
game. The inventory should be a dynamic array of the following items {“Sword”,
|
|
“Health”, “Shield”, “Food”}. Each item in this array should have a quantity
|
|
quantity. The quantity should indicate how many of such items exist, for example
|
|
the inventory could have 3 swords, 2 healths, 1 shield and 0 food. The array is
|
|
dynamic since there is no requirement that all items have to be present in the array.
|
|
Starting empty, allow your user to pick the following options:
|
|
● Add an item to the inventory and continue adding till you have at least one
|
|
of each item.
|
|
● Display the inventory
|
|
● Use an item (reducing the quantity by 1)
|
|
● Delete an item from the inventory when the quantity is 0
|
|
Hint: Use new and delete operators to allocate and deallocate memory for the
|
|
array. Ensure that you handle the memory properly to avoid any memory leaks.
|
|
Function Input/Parameters: ???
|
|
Function Output/Parameters: ???
|
|
Function Output/Returned: ???
|
|
Device Input/Device: ???
|
|
Device Output/Monitor: ???
|
|
Dependencies: ???
|
|
*/
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <cstring>
|
|
#include <vector>
|
|
#include <random>
|
|
#include <algorithm>
|
|
#include <time.h>
|
|
|
|
using namespace std;
|
|
|
|
// class definitions
|
|
class Inventory
|
|
{
|
|
private:
|
|
// variables
|
|
|
|
public:
|
|
Inventory()
|
|
{
|
|
// default constructor
|
|
}
|
|
~Inventory()
|
|
{
|
|
// default destructor
|
|
}
|
|
};
|
|
|
|
// function definitions
|
|
|
|
// main function
|
|
int main()
|
|
{
|
|
//
|
|
return 0;
|
|
}
|