Hw06 题解 (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
VendingMachine
that represents a vending machine for some product. AVendingMachine
object returns strings describing its interactions. Remember to match exactly the strings in the doctests – including punctuation and spacing!Fill in the
VendingMachine
class, adding attributes and methods as appropriate, such that its behavior matches the following doctests: