Hw06 solutions (UCB CS61A@2021 Fall)
OOP
Q1: Vending Machine
In this question you’ll create a vending machine that only outputs a single product and provides change when needed.
Create a class called
VendingMachinethat represents a vending machine for some product. AVending Machineobject returns strings describing its interactions. Remember to match exactly the strings in the doctests – including punctuation and spacing!Fill in the
VendingMachineclass, adding attributes and methods as appropriate, such that its behavior matches the following doctests: