Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions