Question: 3) In this lab, you will implement a vending machine that holds cans of soda. The vending machine can hold a specific number of cans

 3) In this lab, you will implement a vending machine that

3) In this lab, you will implement a vending machine that holds cans of soda. The vending machine can hold a specific number of cans (capacity is 50 cans). To buy a can of soda, the customer needs to insert a token into the machine. When the token is inserted, a can drops from the machine The goal is to determine how many cans in the machine at any given time We need to be able to add cans to the vending machine, and to buy them from it It would also be useful to get the number of cans that the machine contains Translate this informal description into Java class with the name (VendingMachine) and method headers. You will have three methods in your class 1)addCans: increase number of cans using a specific input number as an input to the method, but make sure that the added cans and the available T>, 2) buyCans: decrease number of cans using a specific input number as an 3)getNumberOfCans: return the current number of cans 4) A constructor that takes one parameter which is the initial number of cans in the vending machine For each method you define you have to add comments to the method in javadoc format similar to the way given during the class. You can use the following as a start of your class: private int numOfCans 0:// represent the number of cans in the vending After creating this class you need to create two objects of the vending machine class in the main (vml and vm2). The object vml will have initially 5 cans then add 2 cans to the machine then printout the number of cans. The object vm2 will have initially 10 cans then buy 3 cans and then

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!