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

Will thumbs up, thanks!
 Will thumbs up, thanks! Programming: 29. (10 marks) Consider a simple
vending machine class. The machine accepts tokens and dispenses cans of refreshing

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!