Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I write a cash register program and dispenser program as classes for a candy machine program bfiend sellProduct We have described the method

How can I write a cash register program and dispenser program as classes for a candy machine program
image text in transcribed
bfiend sellProduct We have described the method sellProduct and the other necessary compone next we write the Java application program for the candy machine. The algorithm is as follows: Create the cash register-that is, declare a reference variable of type CashRegister and instantiate the object. Create four dispensers type Dispenser and instantiate the appropriate Dispenser objects. For example, the statement: 1. 2. that is, declare four reference variables of Dispenser candy new Dispenser(100, 50); declares candy to be a reference variable of the Dispenser type and instantiat object candy to hold the candies. The number of items in the object candy is 10 the cost of a candy is 50 cents. 10 1 Chapter B User-Defined Classes and ADTs Create the other objects, such as labels and buttons, as previously described. 3. Display the GUI showing the candy machine, as described at the beginning of this programming example 4. 5. Get and process the selection

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