
The vending machine in Hsin Dorm is stuck. The vending machine owner does not want to deal with it anymore, and let you tinker with it. You, being a smart CS student, will create a VendingMachine class so that the vending machine can run better than before.
Given this code:
You will need to implement VendingMachine class so that it has 2 methods:
1) BUY
no stock.2) RESTOCK
you dont have moneyYou can create any additional functions that you think might be needed.
> Note: the grammar error at dont (not don't) is on purpose
The first line consists of 2 integers:
- The first integer T will be the number of operations on that day
- The second integer N will be the initial balance you get.
The next T line will be one of these commands in this format:
- BUY {name} {quantity} where {name} is the name of the item that the customer buys and
{quantity} is how many items the customer buys
- RESTOCK {name} {price} {quantity} where {name} is the name of the item that you want to restock, {price} is the price that you want to sell that item and {quantity} is how much you restock that item
Output the profit you get after all T operations done. (Profit = Final Balance - Initial Balance)