Question: Need help with this lab public class CoffeeMachineDriver { public static void main(String[] args) { // create a coffee machine CoffeeMachine machine1 = new CoffeeMachine(20);

![void main(String[] args) { // create a coffee machine CoffeeMachine machine1 =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66fa2875f3f3a_38966fa2875895b3.jpg)
Need help with this lab
public class CoffeeMachineDriver { public static void main(String[] args) { // create a coffee machine CoffeeMachine machine1 = new CoffeeMachine(20); // try to make some coffee if (machine1.makeCoffee(3)) System.out.println("Just made 3 cups of coffee!"); else System.out.println("Failed to make coffee! Maybe the machine is off..."); // turn the machine on machine1.turnOn(); // try again to make coffee if (machine1.makeCoffee(1)) System.out.println("Made a cup of coffee!"); // make some more coffee if (machine1.makeCoffee(3)) System.out.println("Just made 3 more cups!"); // check the bean status System.out.println("Machine 1 currently has " + machine1.getGramsOfCoffeeBeans() + " grams of beans."); // try to make 1 too many cups if (machine1.makeCoffee(2)) System.out.println("Another 2 cups made!"); else System.out.println("Failed to make the cups! We may need to add some beans..."); // add some coffee beans machine1.addCoffeeBeans(100); // check the bean status System.out.println("Machine 1 now has " + machine1.getGramsOfCoffeeBeans() + " grams of beans."); // make a lot of cups if (machine1.makeCoffee(18)) System.out.println("18 cups! That's a lot of coffee!"); // check if the machine is clean if (machine1.machineIsClean()) System.out.println("machine1 is clean!"); else { System.out.println("Let's clean this thing!"); machine1.clean(); } // add another coffe machine CoffeeMachine machine2 = new CoffeeMachine(50); // print the number of machines System.out.println("We currently have " + machine1.getNumberOfMachines() + " coffee machines!"); } } Lab 11: "Coffee Machine" Class Write a class called CoffeeMachine; the description of this class is given below Use your class to run the driver program, CoffeeMachineDriver.java CoffeeMachine class Attributes o numCoffeeMachines (static int) o gramsOfCoffeeBeans (int) o numCupsMade (int) o isOn (boolean) o isClean (boolean) . Methods CoffeeMachine (int _gramsofcoffeeBeans) This method initializes gramsofCoffeeBeans to the value passed in to the parameter and also initializes isOn to false and isClean to true and numCupsMade to 0. Also in this constructor, increment numCoffeeMachines by 1 o o o makeCoffee (int numCups) This method will simulate the making of a number of cups of coffee; the exact number of cups is passed to the method. Each cup requires 5 grams of coffee beans. When you make a coffee, subtract 5 from gramsofCoffeeBeans and increment numCupsMade for each cup made What this method needs to do is this: check to see if the machine is on and if there is sufficient coffee beans; if both conditions are met, then make numCups cups of coffee and return true. If the machine is off or if the amount of beans is insufficient, then return false When the number of cups made is 20 or greater, the machine will be considered unclean; so set isClean to false when numCupsMade is greater than or equal to 20 o getGramsofCoffeeBeans () This method returns the value of gramsofCoffeeBeans o addCoffeeBeans (int_gramsToAdd) This method adds_gramsToAdd coffee beans to gramsofCofteeBeans o machineIsOn () This method returns true if the machine is on and false otherwise This method should set isOn to true This method should set isOn to false o turnOn () o turnoff (
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
