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 (i.e., instance variables). Your Product class must include a getter (accessor) method and a setter (mutator) method for each data member.
product_name (String) # The name of the product
units_available (int) # The number of units available
unit_price (double) # The cost per unit
Implement the following member methods of class Product.
boolean purchase(int units):
// Return false if units > units_available. If not reduce units_available 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 refill(int units):
// increments units_available 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 do..while loop and a case-switch statement for the menu.
Rubric
Product class:
Has the 3 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 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!