Question: Using the following Java MicroWave class, create a test class that creates four different instances of a Microwave: (a) A blue Microwave that is turned

Using the following Java MicroWave class, create a test class that creates four different instances of a Microwave:

(a) A blue Microwave that is turned "on" and set to "MEDIUM" heat selection.

(b) A yellow Microwave that is turned "off" and set to "LOW" heat selection.

(c) A silver Microwave that is turned "on" and set to "HIGH" heat selection.

(d) A Microwave created with all default values.

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; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!