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

I am trying to develop one java class for this UML diagram Thermostat Housing te

ID: 3811669 • Letter: I

Question

I am trying to develop one java class for this UML diagram

Thermostat Housing

            temperature: int

            cold: int

            heat: int

            van: int

            on: Boolean

_____________________________________________________

            +Thermostat()

            +turnOn()

            +turnoff()

            +setCold(newCold: int): void

            +setHeat(newHeat:int): void

            +setVan(newVan:int): void

            +coldUp(): void

            +coldDown(): void

            +heatUp(): void

            +heatDown(): void

            +vanOn(): void

            +vanAuto(): void

this is what i did

public class ThermostatHousing {

   public static void main(String[] args) {

       // Declare int

               int temperature ; // Temperature

               int cold = 70; // default cold set at 70 summer time

               int heat= 72; // default heat set at 72 winter time

               int hour = 24;

               boolean on = false; // Temperature off

               int x = (int)(Math.random() * 24); // code to create time

           }

              public int temerature;

               public void thermostat(){ // Thermostat constructor object of the class

               }

               public void turnOn() { // turn on Thermostat

                   boolean on = true;

               }

               public void turnOff(){ //turn off Thermostat

                   boolean on = false;

               }

               public void cold(int cold) { // set cold temperature

                   boolean on = false;

                  

                  

                   int newCold = 0;

                   if ( on && cold >=70 && cold <= 24)

                       // create object of the cold class

                       cold = newCold;

               }

               public void heat(int heat) { // set cold temperature

                   boolean on = false;

                  

                  

                   int newHeat = 0;

                   if ( on && heat >=72 && heat <= 24)

                       // create object of the heat class

                       heat = newHeat;

               }

   }

Explanation / Answer

class ThermoStat {
   private int temperature;
   private int cold;
   private int heat;
   private int van;
   private boolean on;
   private final int temp_per_up_down = 1; // temperature difference with one Up or
                                           // down

   public ThermoStat() {
   }

   public int getTemperature() {
       return temperature;
   }

   public void setTemperature(int temperature) {
       this.temperature = temperature;
   }

   public int getCold() {
       return cold;
   }

   public void setCold(int cold) {
       this.cold = cold;
   }

   public int getHeat() {
       return heat;
   }

   public void setHeat(int heat) {
       this.heat = heat;
   }

   public int getVan() {
       return van;
   }

   public void setVan(int van) {
       this.van = van;
   }

   public boolean isOn() {
       return on;
   }

   public void setOn(boolean on) {
       this.on = on;
   }

   public void turnOn() {
       setOn(true);
   }

   public void turnOff() {
       setOn(false);
   }

   public void coldUp() {
       if (isOn()) {
           setCold(this.getCold() + temp_per_up_down);

       } else {
           turnOn();
           setCold(this.getCold() + temp_per_up_down);

       }

   }

   public void coldDown() {
       if (isOn()) {
           setCold(this.getCold() - temp_per_up_down);

       } else {
           turnOn();
           setCold(this.getCold() - temp_per_up_down);

       }

   }

   public void heatUp() {
       if (isOn()) {
           setHeat(this.getHeat() + temp_per_up_down);
       } else {
           turnOn();
           setHeat(this.getHeat() + temp_per_up_down);
       }

   }

   public void heatDown() {
       if (isOn()) {
           setHeat(this.getHeat() - temp_per_up_down);

       } else {
           turnOn();
           setHeat(this.getHeat() - temp_per_up_down);

       }
       setCold(this.getHeat() - temp_per_up_down);

   }

   // From the question Not sure what is VAN in thermostat
   public void vanOn() {
      

   }

   public void vanAuto() {

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote