I am trying to get code that implements a textual view and a graphical view of the conversion using the MVC pattern. Currently, my code converts temperature from Fahrenheit to Celsius.
I think I have to use the Observable class and Observer interface in the Java standard library for the MVC pattern implementation, but I could be wrong.
This is what i got so far.
public class Temperature {
public static String CUnit = " °C";
private double tempF;
private double tempC;
public Temperature() {
tempF=0;
}
public Temperature(double tempF) {
this.setTempF(tempF);
}
public double getTempF() {
return tempF;
}
public void setTempF(double tempF) {
this.tempF = tempF;
}
private void convertFtoC(){
tempC = (getTempF()-32) * 5/9;
}
public double getTempC() {
convertFtoC();
return tempC;
}
public void setTempC(double tempC) {
this.tempC = tempC;
}
}
Am I close? Any help is appreciated
Thank you