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 . - ) - the current temperature of the oven. Should not be greater than maxTemp or less than 0 . If currentTemp is greater than maxTemp, it should be set to maxTemp. If currentTemp is less than 0 , it should be set to 0 . Constructors - public Oven (int maxTemperature, int startTemperature) - constructs and an object of type with the given maxTemperature and startTemperature. Methods - public int getMaxTemp() - returns the of the oven. - public int getCurrentTemp()- returns the of the oven. - - sets the of the oven to 0 if the of the oven is greater than 0. - \( \quad- \) return true if of the oven is greater than 0. - \( \quad \) - sets of the oven to temp. If temp is greater than to then 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. 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 \) " \( \mathrm{p} \) 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. New oven with a maximum temperature of 450 and a starting temperature of \( \theta \) 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.
Files
// 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 \) Finish writing the Oven class that represents \( / / \) temperature, but no less than \( \theta \). an oven. This class has the variables, public Oven(int maxTemperature, int startTemperature) \{ constructors and methods detailed below. You should write code implementing the \} methods and constructors so they behave as // Returns the maximum temperature of an oven public int getMaxTemp() described. \{ \} Variables // Returns the current temperature of an oven public int getCurrentTemp() - private int maxTemp - the \{ maximum temperature of the oven. 3 This value should not be changed // Turns an oven off by setting the current temperature to \( \theta \). after the oven is constructed. If the public void turnoff() temperature is greater than 500 or \{ less than 0 , it should be changed to \} 500. - private int currentTemp - the // Returns whether the current temperature of an oven is greater than 0 . current temperature of the oven. // return false if the current temperature is 0 . public boolean ison() Should not be greater than maxTemp \{ or less than 0 . If currentTemp is greater than maxTemp, it should be \} set to maxTemp. If currentTemp is less // Sets the current temperature of an oven to the given value. Remember, // the current temperature should not exceed the max temp. than \( O \), it should be set to \( O \). public void preheat(int temp) \{ Constructors
System.out.println("Enter the temperature to preheat the oven to:"); Should not be greater than maxTemp