Question: Using the following Java Class.... public class MicroWave { // Represent possible microwave heat selections private final int LOW = 1; private final int MEDIUM
Using the following Java Class....
public class MicroWave {
// Represent possible microwave heat selections private final int LOW = 1; private final int MEDIUM = 2; private final int HIGH = 3; // specifies the microwave heat selection(default is MEDIUM) private int heatSelection; // specifies whether the microwave is on private boolean on; private String color; public MicroWave(int heatSelection, boolean on, String color) { this.heatSelection = heatSelection; this.on = on; this.color = color; } public MicroWave() { this.heatSelection = MEDIUM; this.on = false; this.color = "black"; }
public int getHeatSelection() { return heatSelection; }
public void setHeatSelection(int heatSelection) { this.heatSelection = heatSelection; }
public boolean isOn() { return on; }
public void setOn(boolean on) { this.on = on; }
public String getColor() { return color; }
@Override public String toString() { String result = "MicroWave color=" + color + " heat selection: "; if(heatSelection == LOW) { result += "LOW"; } else if(heatSelection == MEDIUM) { result += "MEDIUM"; } else { result += "HIGH"; } return result; } }
create a test class that does the following:
1. Creates four instances of a MicroWave:
(a) A blue microwave that is turned "on" and set to "MEDIUM" heat selection.
(b) A green microwave that is turned "off" and set to "LOW" heat selection.
(c) A blue microwave that is turned "on" and set to "HIGH" heat selection.
(d) A microwave created with all default values.
2. Performs an automated test against each Microwave. Test should be placed in a static method with the following signature in the test class.
public static void test(MicroWave[] microWaves)
(a) For simplicity, test method will just iterate over the array of MicroWaves and log a text nessage to a file named "test.log" for each microwave test. Message should consist of the toString() of the microwave along with phrases "pass" or "fail" indicating the result of the test. Microwave "fails" the test if its off.
Sample log file content:
BLUE MEDIUM PASS
GREEN LOW FAIL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
