Finish writing the Oven class that represents an oven. This class has the variables, constructors and methods detailed below....
This problem has been solved!
Do you need an answer to a question different from the above? Ask your question!
Question:






Transcribed Image Text:
Finish writing the Oven class that represents an oven. This class has the variables, constructors and methods detailed below. You should write code implementing the methods and constructors so they behave as described. Variables private int maxTemp - the maximum temperature of the oven. This value should not be changed after the oven is constructed. If the temperature is greater than 500 or less than 0, it should be changed to 500. private int current Temp - the current temperature of the oven. Should not be greater than maxTemp or less than 0. Constructors . . . Methods . . public Oven (int maxTemperature, int startTemperature) constructs and an object of type oven with the given maxTemperature and startTemperature. . - public int getMaxTemp() - returns the maxTemp of the oven. public int getCurrent Temp() - returns the current Temp of the oven. public void turnoff() - sets the current Temp of the oven to 0 if the current Temp of the oven is greater than 0. public boolean ison() - return true if current Temp of the oven is greater than 0. public void preheat (int temp) - sets current Temp of the oven to temp. If temp is greater than maxTemp, then set currentTemp to maxTemp. If temp is less than or equal to 0, do nothing. To test your code before submission, use the file runner_Oven.java. Run the main method in the runner Oven class and verify that the program produces the expected output. A sample run is shown below, but you should also try a range of other inputs to test your code more thoroughly. Translate G Google (1) I need some hel... If the runner file does not compile then you should attempt to fix your Oven class before checking your code for a score. Start by checking that the signatures and return types of your Oven methods match the descriptions exactly. You should also not add a main method to your Oven class, since you may not be able to run your code, and it will not be scored correctly when you check it. Sample run Maximum oven temperature: 450 Starting temperature of the oven: 70 New oven with a maximum temperature of 450 and a starting temperature of 70 degrees. To preheat the oven enter "p", to turn the oven off enter "o", to restart enter "r", to quit enter "q" Р Enter the temperature to preheat the oven to: 350 Current temperature of the oven is now 350 degrees. New oven with a maximum temperature of 450 and a starting temperature of 350 degrees. To preheat the oven enter "p", to turn the oven off enter "o", to restart enter "r", to quit enter "q" Turning the oven off. O New oven with a maximum temperature of 450 and a starting temperature of 0 degrees. To preheat the oven enter "p", to turn the oven off enter "o", to restart enter "r", to quit enter "q" q Hint - Start by writing the 3 accessor methods - getMaxTemp, getCurrentTemp and isOn. These methods just need to return the relevant member variables. Once this is done you will be able to compile and run the runner class to test your code. Then you can focus on writing and testing the more difficult remaining methods. XX Files Oven.java runner_Oven.java STATUS 1 2 3 8 9 10 11 4* { 5 6 7 ❤ DANHLARIG 12 13 14 15 16 17 18 19 ▾ 20 21 22 O NOT SUBMITTED 23 24 25 26 27 - 28 29 30 31 import java.util.Scanner; public class runner Oven public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Maximum oven temperature: "); int maxTemp = scan.nextInt (); System.out.println("Starting temperature of the oven :"); int startTemp = scan.nextInt (); Oven oven = new Oven (maxTemp, startTemp); String instruction = ""; while (!instruction.equals("q")) { SAVE SUBMIT System.out.println("New oven with a maximum temperature of " + oven.getMaxTemp() + " and a starting temperature of " + oven.getCurrent Temp () + " degrees."); if (instruction.equals("p")) { System.out.println("To preheat the oven enter \"p\" to turn the oven off enter" + " \"0\", to restart enter \"r\", to quit enter \"q\""); || instruction = scan.next(); System.out.println("Enter the temperature to preheat the oven to: "); scan.nextInt (); int temp oven.preheat (temp); "صاممممعمه System.out.println("Current temperature of the oven is now " + oven.getCurrent Temp() + INSTRUCTIONS RUN CODE GRADING Sample run be able to run your code, and it will not be scored correctly when you check it. → HISTORY Maximum oven temperature: 450 Starting temperature of the of 70 New oven with a maximum tempe To preheat the oven enter "p" Р Enter the temperature to preh 350 Current temperature of the ov New oven with a maximum tempe To preheat the oven enter "p" O Turning the oven off. New oven with a maximum tempe To preheat the oven enter "p" q Hint - Start by writing the 3 accessor methods - getMaxTemp, getCurrentTemp and isOn. These methods just need to return the relevant member variables. Once this is done you will be able to compile and run the runner class to Over.java runner Oven.java 13 14 15 16 17 18 19 ▾ 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 } } Oven oven = new Oven (maxTemp, startTemp); String instruction = ""; while (!instruction.equals("q")) { } System.out.println("New oven with a maximum temperature of " + oven.getMaxTemp() + " and a starting temperature of + oven.getCurrent Temp () + " degrees."); System.out.println("To preheat the oven enter \"p\" , to turn the oven off enter" + "\"0\", to restart enter \"r\", to quit enter \"q\""); instruction = scan.next(); if (instruction.equals("p")) { System.out.println("Enter the temperature to preheat the oven to:"); scan.nextInt (); int temp oven.preheat (temp); } System.out.println("Current temperature of the oven is now " + oven.getCurrent Temp() + " degrees\n"); } else if (instruction.equals("o")) { System.out.println("Turning the oven off. \n"); oven. turnoff (); Tot be scored correctly when you check it. Sample run Maximum oven temperature: 450 Starting temperature of the o 70 New oven with a maximum tempe To preheat the oven enter "p" Р Enter the temperature to preh 350 Current temperature of the ov New oven with a maximum tempe To preheat the oven enter "p" 0 Turning the oven off. New oven with a maximum tempe To preheat the oven enter "p" q Hint - Start by writing the 3 accessor methods - getMaxTemp, getCurrentTemp and isOn. These methods just need to return the relevant member variables. Once this is done you will be able to compile and run the runner class to e G Google Files Oven.java runner Oven.java (1) I need some hel... 1 2 - 3 4 tin ∞0 a 5 6 7 8 9 10 11 12 13 14- 15 16 17 18 19 20 - 21 22 23 24 25 26 ▼ 27 28 29 30 31 32 - 33 34 NOT SUBMITTED SAVE oven private int maxTemp; public class Oven { // Represents the maximum possible temperature of an SUBMIT // Represents the current temperature of an oven private int currentTemp; // Constructs an oven with the given max temp and starting temp. The maximum // temperature of an oven must be greater than 0, but no more than 500. // The starting temperature should be less than or equal to the maximum t // temperature, but no less than 0. public Oven (int maxTemperature, int startTemperature) { } // Returns the maximum temperature of an oven. public int getMaxTemp() { } // Returns the current temperature of an oven. public int getCurrentTemp() { } // Turns an oven off by setting the current temperature to 0. public void turnoff () { } D INSTRUCTIONS RUN CODE GRADING } // Returns the maximum temperature of an oven public int getMaxTemp() } // Returns the current temperature of an oven public int getCurrentTemp() } // Turns an oven off by setting the current temperature to 0. public public void turnoff () } // Returns whether the current temperature of an oven is greater than 0. Should 77 return false if the current temperature is 0. public boolean ison() { } } // Sets the current temperature of an oven to the given value. Remember, // the current temperature should not exceed the max temp. public void preheat (int temp) HISTORY } ENC ( 2:20 AM 10 1J 16 17 18 19 20- 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 - 40 41 42 43 44 45 46 - 47 48 49 50 } // Returns the maximum temperature of an oven public int getMaxTemp() { } // Returns the current temperature of an oven public int getCurrentTemp() { } // Turns an oven off by setting the current temperature to 0. public void turnoff () { } // Returns whether the current temperature of an oven is greater than 0. Should // return false if the current temperature is 0. public boolean ison () { } // Sets the current temperature of an oven to the given value. Remember, // the current temperature should not exceed the temp. public void preheat (int temp) { } INSTRUCTIONS RUN CODE { } // Returns the maximum temperature of an oven public int getMaxTemp() GRADING OneDrive HISTORY } // Returns the current temperature of an oven public int getCurrentTemp() } // Turns an oven off by setting the current temperature to 0. public void turnoff() } // Returns whether the current temperature of an oven is greater than 0. Should // return false if the current temperature is 0. public boolean ison() { } // Sets the current temperature of an oven to the given value. Remember, // the current temperature Screenshot saved The screenshot was added to your OneDrive.
Expert Answer:
Answer rating: 100% (QA)
Step 1 The definitions of Oven java is implemented using Jav View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
View Solution
Create a free account to access the answer
Cannot find your solution?
Post a FREE question now and get an answer within minutes.
* Average response time.
Posted Date: August 09, 2023 08:42:01