Question: Will thumbs up, thanks! Programming: 29. (10 marks) Consider a simple vending machine class. The machine accepts tokens and dispenses cans of refreshing beverages. Write
Programming: 29. (10 marks) Consider a simple vending machine class. The machine accepts tokens and dispenses cans of refreshing beverages. Write a complete class (on the next page) as described below The class has two instance data fields; one to keep track of the number of cans in the machine and one to keep track of the number of tokens (think coins) collected There should be two constructors. One takes no arguments and starts with 50 cans and zero tokens. The other takes one argument, the initial number of cans in the machine There should be a method to purchase a drink which adds one token to the machine and subtracts one can-assuming there are still cans in the machine to be purchased There should be one method to add cans to the machine . There should be separale methods to return the number of cans remaining and the number of tokens collected Bonus (+2 marks): Write a toString) method to allow for easy printing of a vending machine object For any other assumptions you are making, use comments. Don't write Java Docs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
