Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assumptions 1. For now, the CokeMachine only dispenses Coke and no other types of items. 2. Payments are entered in pennies - $0.50 is entered

Assumptions

1. For now, the CokeMachine only dispenses Coke and no other types of items.

2. Payments are entered in pennies - $0.50 is entered as 50, $1.00 is entered as 100.

3. Any displays of change will be in dollars and cents.

4. Any payment entered cannot be used as part of the dispensed change. For example, if the user enter 1234 ($12.54) for payment, then the machine will only dispense a Coke if is has enough change for 1204.

5. When restocking the machine, the entire restock request has to fit. If the entire quantity does not fit, then the restock request is rejected. UML Use the following UML to create the outline of your CokeMachine class. Please note that exact names (spellings and case) should be used.

CokeMachine

- machineName : string

- changeLevel : int

- maxChangeCapacity : int = 5000

- CokePrice : int

- inventoryLevel : int

- maxInventoryCapacity : int = 100

+ CokeMachine(name : string, cost : int, change : int, inventory : int) : CokeMachine

+ getMachineName() : string

+ buyACoke(payment : int, change : string, action : int) : bool

+ getInventoryLevel() : int

+ getMaxInventoryCapacity() : int

+ incrementInventory(amountToAdd : int) : bool

+ getChangeLevel() : string

+ incrementChangeLevel(amountToAdd : int) : bool

+ getMaxChangeCapacity() : string

+ getCokePrice() : string

+ displayMoney(amount : int) : string

Create a menu in your .cpp file to use your Coke Machine. 0. Walk away 1. Buy a Coke 2. Restock Machine 3. Add change 4. Display Machine Info When you instantiate your CokeMachine object, your constructor will assign Your machine's name The price of a single Coke The amount of change in the machine The number of items (inventory level) in the machine The constructor I used (that you will see in the example output) is CokeMachine MyCokeMachine{"CSE 1325 Coke Machine", 50, 500, 100}; The max capacities of the machine (inventory and change) are set in the initalizers of the data members. These values are given in the UML. Any printing to the screen should take place in the .cpp file. Your CokeMachine class should not have any cins or couts in it. The UML is set up such that all functions return the information needed to print messages to the screen. Additional Information about the using of action in buyACoke() buyACoke() returns true/false to indicate whether or not the function worked. buyACoke() also sets action to different values depending on what happened while executing the code in buyACoke(). For example, if a Coke costs $0.50 and a payment of 30 cents is entered, then buyACoke() will fail but your .cpp program needs to know why so it can print a message to inform the user what went wrong your .cpp program needs to know what action to take. buyACoke() would assign a specific value to action that would relay back to your .cpp program what happened so that it can print a message about it. For example, buyACoke() if payment is insufficient, then action would be set to 3 (for example) .cpp program get action back from buyACoke() and print a message about insufficient funds because action is 3 You will need to define multiple values for action to mean the various actions that your .cpp program needs to take based on what happened when buyACoke() was called. I used an enumerated type so that I could use words instead of numbers to make my code easier to read. enum ACTION {OK, NOINVENTORY, NOCHANGE, INSUFFICIENTFUNDS, EXACTCHANGE};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

Question What is a secular trust?

Answered: 1 week ago