Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

uml1 Item -string name -int cost -int quantity +item (string,int,int) +string ge

ID: 3611546 • Letter: U

Question

uml1 Item -string name -int cost -int quantity +item (string,int,int) +string getName() +string getCost() //formatted $d.cc +int get getQuantity() +void setName(string) +void setCost() +void setQuantity uml2 Machine -Item[9] items -int money +istream& operator >> (istream& in) +void displayState() +void depositMoney() +void purchaseItem() this is a general description of the problem i am try to do:Write a simulation for a high-tech vending machine. After aninitial state is established for the machine(i.e., the items forsale, their costs, and the initial inventory counts), the user canhave an interactive dialog with the simulation. In this dialog theuser 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 returnany change the user is owed

For simplicity, assume that the vending machine has exactly ninetypes of item for sale.

Use the following data as input to initialize the state of themachine.

Tortilla_Chips 60 3
Pretzels 60 10
Popcorn 60 5
Cheese_Crackers 40 2
Creme_Cookies 65 1
Mint_Gum 25 5
Chocolate_Bar 55 3
Licorice 85 9
Fruit_Chews 55 7

Create a text file with the above data and overload the >>operator within the machine class to read this data and create thecorresponding objects.

Items should be organized and displayed as a 3x3 matrix.

Item0 Item1 Item2
Item3 Item4 Item5
Item6 Item7 Item8

You will define two classes, an item class and a machine class, toimplement this simulation. The UML for theses classes is shownbelow. Problem Statement
Write a vending machine simulation in which the user is able to gothrough an interactively choose to: view the machines status,deposit money, and purchase an item.

Input Output Description
1. displayState() will display each of the items names andavailable quantities in the machine in matrix form as well as howmuch money has been inserted into the vending machine so far.

2. depositMoney() will take an amount of money to deposit as inputby the user.

3. purchaseItem() will take as input the number of the item to bepurchased. It will produce as output an error message if the userhas not input enough money for a given item, or will display theamount of change the user is to get back if there is enoughmoney.

4. the >> operator will read data in the form of text. Eachline of data contains the name, price, and quantity of one itemthat is to be added to the machines item set.
Thank you very much for any help.

Explanation / Answer

Let me give you a bit to start with... #include #include using namespace std; class Item{ private: //item properties string name; //item name int cost; //cost in cents int quantity; //quantity remaining public: //public methods Item(string temp_name, int temp_cost, int temp_qty); string get_name(void); string get_cost(void); int get_quantity(void); void set_name(string temp_name); void set_cost(int temp_cost); void set_quantity(int temp_quantity); } //Now that declares all of the stuff that you need to implement //here a few of the methods you would need to implement //i'll leave the rest to you as they follow a similar pattern Item::Item(tring temp_name, int temp_cost, int temp_qty){ name = temp_name; cost = temp_cost; quantity = temp_qty; } string Item::get_name(void){ return name; } void Item::set_name(string temp_name){ name = temp_name; } The others for the item class follow a similar manner. Theonly exception is the get_cost. You need to convert aninteger to a string there. Look up stringstreams or sprintffor that. Once you finish constructing the Item class, then you can start thevending machine class.I would definitely construct the item classfirst though. I've given you a decent start. Once youfinish the Item class (or get stuck again on it), them come backhere for further help.