Question
On following script suggest different constructors and/or methods and/or behavior of the class that would be consistent with the real object that the class is
On following script suggest different constructors and/or methods and/or behavior of the class that would be consistent with the real object that the class is modeling, or suggest a different version of the code. Th main method should demonstrate the correct functionality of the additions/modifications:
import java.util.Scanner;
public class WK2OlivaresD { static Scanner input = new Scanner(System.in); //create scanner public static class Microwave { private int watts; private int time; private int start; public void turnOn () { //initiate microwave System.out.println("Power On"); }//end of turnOn public void setWatts (int newWatts) { System.out.println("Choose Watts Power"); this.watts= input.nextInt(); } //end of setWatts public int getWatts () { return watts; }//end of getWatts public void setTime() { // set the time System.out.println("Choose Time in seconds:"); this.time = input.nextInt(); } // end of setTime public int getTime () { return time; } public void Start () { //start the cooking System.out.println("Start!"); for (int i=this.time; i>0; i-=1) { System.out.print(i+".. "); }//end of for loop System.out.println("BEEP! BEEP! BEEP!"); //indicate cooking is done } //end of start
public static void main(String[] args) { //execute the program using the methods Microwave m = new Microwave(); m.turnOn(); m.setWatts(0); m.setTime(); m.Start();
// print all your variables in a statement from the program System.out.println("Your food is ready!"); System.out.println("You cooked with a power of "+m.getWatts()+" watts for " +m.getTime()+" seconds"); System.out.print("Enjoy"); } //end of main } //end of Microwave class
}//end of class
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