Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this lab, we provide a complete class that simulates a simple vending machine. Review the code in VendingMachine.java below. Click on the orange Main.java
For this lab, we provide a complete class that simulates a simple vending machine. Review the code in "VendingMachine.java below. Click on the orange "Main.java" link to toggle to the other file. Then complete 'Main.java" to create an object and perform several operations as indicated in the FIX ME comments. LAB ACTIVITY5.16.T: zyLab: vending Machine Current file: Mai...ava Load default template... 1 public class Main t public static void main(String[] args) { FIX ME: define and instantate a VendingMachine object 4 //FIX ME: invoke purchaseO to buy one drink FIX ME: invoke purchase to buy one drink //FIX ME: invoke restockO) to add 30 bottles 7 8 10 FIX ME: invoke reportO to display vending machine status 12 13 14 File is marked as read only Current file: VendingMachine.java 2 Simulates a simple vending machine with operations 3 to purchase drinks and check inventory. 4 5 eauthor Scott Grissom 7 public class VendingMachine 9/**number of bottle in stock */ 10 private int bottles; 13 Constructor sets inventory to 20 15 public VendingMachineO 16 bottles-20; 17 18 20 Purchase one bottle 22 public void purchaseO 23 24 25 bottles- 27 @returns number of bottles in stock 29 public int getInventoryO 30 31 32 return bottles 34 Restock machine with more inventory 35 eparam number of bottles added to machine 37 38 39 public void restock(int amount)1 bottles bottles +amount 39 40 42 Report machine status 44 public void report i 45 46 47 System.out.printlnC"Inventory:"+ bottles); 49 This method must be here for testing only 51 public static void main(String args) t 52 53 3 54
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started