Question: Implement your own Product class. Your Product class must have the following data members ( i . e . , instance variables ) . Your
Implement your own Product class. Your Product class must have the following data members ie instance variables Your Product class must include a getter accessor method and a setter mutator method for each data member.
productname String # The name of the product
unitsavailable int # The number of units available
unitprice double # The cost per unit
Implement the following member methods of class Product.
boolean purchaseint units:
Return false if units unitsavailable. If not reduce unitsavailable by units and then return true.
Optional: Show the user the total price, take payment from them using a Scanner object, and make change if needed.
units: The number of units of this product that the user wants to purchase
void refillint units:
increments unitsavailable by units
units: The number of units of this product that we are adding
Implement your own VendingMachine class containing a main method that
instantiates and array list of about four or five Product objects,
provides the user with a menu, and then lets the user select a product, and then choose to purchase units of the product, refill it go back to the menu, or exit the menu,
uses a dowhile loop and a caseswitch statement for the menu.
Rubric
Product class:
Has the required attributes
Correctly implements getters and setters for each attribute.
purchase is correctly implemented refill is correctly implemented
VendingMachine class:
main is correctly implemented.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
