Question: Please help public class hairdryer { // data fields private int Temp; private boolean isOn; //constructor with Arguments public hairdryer(int temp ,boolean isOnOff ) {

Please help

public class hairdryer {

// data fields

private int Temp;

private boolean isOn;

//constructor with Arguments

public hairdryer(int temp ,boolean isOnOff ) {

Temp=temp;

isOn = isOnOff;

}

public int getTemp() {

return Temp;

}

//method that returns whether hair dryer is on or not

public boolean hairdryerIsOnOff() {

return isOn;

}

//setters

//method that sets the temp of the hair dryer

public void setHighTemp(int temp) {

this.Temp = temp;

}

//method that sets the Cool temp of the hair dryer

public void setLowTemp(int temp)

{

this.Temp= temp;

}

//method that sets on or off to the hair dryer

public void setOn(boolean on) {

this.isOn = on;

}

public String toString() {

return " state is "+hairdryerIsOnOff() + " Temperature is "+getTemp() ;

}

// main method to run the program

public static void hairdryer(String[] args) {

hairdryer hair_dryer = new hairdryer(30,true);

hair_dryer.setOn(true);

//hair_dryer.setCoolTemp;

//hair_dryer.setHighTemp;

if(hair_dryer.hairdryerIsOnOff()==true)

{

System.out.println("Hair dryer is hot");

}

else if(hair_dryer.hairdryerIsOnOff()==false)

{

System.out.println("Hair dryer is cool");

}

System.out.println(hair_dryer.toString());

hair_dryer.setOn(false);

System.out.println("Checking after switch off the hair dryer");

if(hair_dryer.hairdryerIsOnOff()==true)

{

System.out.println("Hair dryer is hot");

}

else if(hair_dryer.hairdryerIsOnOff()==false)

{

System.out.println("Hair dryer is cool");

}

System.out.println(hair_dryer.toString());

}

}

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 Programming Questions!