Hi everyone im having trouble with writing this program. Any help will be appreciated!
Write a simulation for a high-tech vending machine. After an initial state is established for the machine(i.e., the items for sale, their costs, and the initial inventory counts), the user can have an interactive dialog with the simulation. In this dialog the user can:
1. View the current state of the machine
2. Deposit money into the machine
3. Purchase an item in the machine, which subsequently will return any change the user is owed
For simplicity, assume that the vending machine has exactly nine types of item for sale.
Use the following data as input to initialize the state of the machine.
You will define two classes, an item class and a machine class, to implement this simulation. The UML for theses classes is shown below.
class Item
{
public:
Item();
Item(string,int,int);
string getName();
string getCost();
int getQuantity();
friend istream& operator >>(istream& in, Machine& m);
private:
int money;
Item items;
int purchase;
};
1. displayState() will display each of the items names and available quantities in the machine in matrix form as well as how much money has been inserted into the vending machine so far.
2. depositMoney() will take an amount of money to deposit as input by the user.
3. purchaseItem() will take as input the number of the item to be purchased. It will produce as output an error message if the user has not input enough money for a given item, or will display the amount of change the user is to get back if there is enough money.
4. the >> operator will read data in the form of text. Each line of data contains the name, price, and quantity of one item that is to be added to the machines item set.