Search for question
Question

You are writing a system controlling a vending machine that dispenses snacks and

soft drinks. There are several types of snacks and soft drinks. You can assume that

you have three types of snacks SnackTypeA, SnackTypeB, and SnackTypeC and each

type has 3 or more items available in the vending machine (i.e. a total of 6 or more

snacks). Each item in a type is identified by a unique name (e.g. "KitKat" may be a

product of type SnackTypeA and "CrispyCream" may be another item in

SnackTypeA also) and each item has a price. The same holds for the soft drinks

where we assume that there are three types of soft drinks DrinkTypeA, DrinkTypeB

and DrinkTypeC. The system, keeps track of a) the items the vending machine has on

its selves, b) the item selected by the customer, b) the amount of money deposited by

a customer, c) whether change or not is required, d) whether insufficient funds are

deposited, and e) whether the user selected an item for which is not available in stock.

When a selection is made and an amount of money is deposited, the machine will

either:

- deliver a product and no change (if exact funds are deposited)

- deliver a product and the appropriate change (if more funds than needed are

deposited),

- deliver no product due to insufficient funds deposited for a given selection and the

funds are returned to the user (just use a print statement indicating that the funds are

returned),

- deliver no product due to the item not being available and the funds are returned to

the user, (just use a print statement indicating that the funds are returned).