Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi I need help with this lab problem Along with the output thanks. (2a) Model a

ID: 3806684 • Letter: H

Question

Hi I need help with this lab problem Along with the output thanks. (2a) Model a physical entity as a Java class (7o points) focus on Encapsulation: This is an Object Modeling/Programming exercise albeit around 1 (maybe 2) Object. Using the Radio Object we reviewed in class as a point of reference, think of a common (or maybe, not so common) physical device or appliance that's worthy of modeling as an Object. Consider the following: a. The basic operations/functionality of your device/appliance become public methods of the implementing Class (e.g., on, off, go, start, stop, b. The internal structure (or how you envision the internal structure) of your device/appliance become the data members of the implementing Class. This would include the internal piece-parts of the device and well as "state

Explanation / Answer

PROGRAM CODE:

MicroWave.java

package simple;

public class MicroWave {

  

   private long serialNumber;

   private double temperature;

   private boolean powerState;

   private String options[];

   private int selectedOption;

   private String type;

   private double power;

   private int timer;

  

   public MicroWave() {

       serialNumber = 23275673;

       temperature = 0.00;

       powerState = false;

       options = new String[]{"Warm", "Boil", "Heat", "Bake"};

       selectedOption = 0;

       type = "Digital Touch System";

       power = 1000;

       timer = 0;

   }

  

   public void setTemperature(double temp)

   {

       temperature = temp;

   }

  

   public boolean isOn()

   {

       return powerState;

   }

  

   public boolean isOff()

   {

       return powerState;

   }

   public void selectOption(int id)

   {

       if(id>0 && id<5)

       {

           selectedOption = id;

       }

   }

  

   public boolean isTemperatureSet()

   {

       if(temperature > 0)

           return true;

       else return false;

   }

  

   public void turnOn()

   {

       powerState = true;

   }

  

   public void turnOff()

   {

       powerState = false;

   }

  

   public void resetTemperature()

   {

       temperature = 0.00;

   }

  

   public void setTimer(int time)

   {

       timer = time;

   }

  

   public boolean isTimerSet()

   {

       if(timer > 0)

           return true;

       else return false;

   }

  

   public void incrementTemperature(double addtemp)

   {

       temperature += addtemp;

   }

  

   @Override

   public String toString() {

       String value = "Microwave Instance: [SerialNumber=" + serialNumber + ", PowerState=" + powerState + ", Temperature="

               + temperature + ", SelectedOption=" + options[selectedOption] + ", Type=" + type + ", Power=" + power

               + "Timer=" + timer + "]";

       return value;

   }

}

OUTPUT:

Microwave Instance: [SerialNumber=23275673, PowerState=false, Temperature=0.0, SelectedOption=Warm, Type=Digital Touch System, Power=1000.0Timer=0]

Microwave Instance: [SerialNumber=23275673, PowerState=true, Temperature=32.0, SelectedOption=Warm, Type=Digital Touch System, Power=1000.0Timer=0]