question in programing 1

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadlines.


Order a Similar Paper Order a Different Paper

The code shown below attempts to utilize the Adapter design pattern to allow the Client to use the methods provided by the CelciusReporter class. The Adapter is the TemperatureReporter class.

For this question, please complete the Adapter class by providing the necessary code for all the methods whose body contain the comment// Need to provide code here.

// This is the Client

public class Client {

public static void main(String[] args)

{

TempratureInfo tempInfo = new TempratureReporter();

System.out.println(“Adapter test”);

// Set the temp in Celcius.

//

tempInfo.setTemperatureInC(0);

System.out.println(“temp in C:” + tempInfo.getTemperatureInC());

System.out.println(“temp in F:” + tempInfo.getTemperatureInF());

// Set the temp in Fahrenheit.

//

setTemperatureInF(85);

System.out.println(“temp in C:” + tempInfo.getTemperatureInC());

System.out.println(“temp in F:” + tempInfo.getTemperatureInF());

}

}

// This is the Adaptee class

public class CelciusReporter {

double temperatureInC;

public double getTemperature() {

return temperatureInC;

}

public void setTemperature(double temperatureInC) {

this.temperatureInC = temperatureInC;

}

}

// This is the Adapter class

public class TemperatureReporter {

CelciusReporter celciusReporter();

public TempratureReporter() {

celciusReporter = new CelciusReporter();

}

public double getTempratureInC() {

// Need to provide code here

}

public double getTepratureInF() {

// Need to provide code here

}

public void setTempratureinC(double tempratureInC) {

// Need to provide code here

}

public void setTempratureinF(double tempratureInF) {

// Need to provide code here

}

private double fToC(double f) {

return ((f – 32) * 5 / 9);

}

private double cToF(double c) {

return ((c * 9 / 5) + 32);

}

}

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadlines.

Get 15% discount for your first order


Order a Similar Paper Order a Different Paper
Writerbay.net