Problem

Write a simulation for a high-tech vending machine. After an initial state is established...

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 view the current state of the machine, deposit money (cents) into the machine, purchase an item in the machine, get the item and any change due in return, and execute a coin return function to get back all deposited money. For simplicity, assume that the vending machine has exactly nine types of item for sale. An item can be defined using three objects:

string, represent the name of the item

The cost (in cents) of the item

The quantity of the item initially available for sale

The following data can be used to establish the initial state of the machine:

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

Conceptually, the items can be organized as a 3-by-3 matrix as follows:

A1 A2 A3

B1 B2 B3

C1 C2 C3

Define two classes, an item class and a machine class, to implement this simulation.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 10
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT