Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions