follow up to my question before this I'm continuing here due to text limit in comments
link to older question https://codegym.cc/help/13698
so a classmate was able to get me so far but I've lost contact with them so I'm back here for help. The code that we wrote needs to work with the demo file both of which are included line 39 of the demo program keeps causing a compile time error message
ThermometerDemo.java:39: error: method setScale in class Thermometer cannot be applied to given types;
therm1.setScale("F");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
any ideas?
here's the program that we wrote
public class Thermometer
{
private double temp;
private String tempScale;
private String scale;
public Thermometer()
{
temp=0;
tempScale = "C";
}
public Thermometer (double temperature, String unitScale)
{
this.temp = temperature;
this.tempScale = unitScale;
}
public double getTemp() {
return temp;
}
public void setTemp(double temp) {
this.temp = temp;
}
public String getTempScale() {
return tempScale;
}
public String setScale(){
return scale;
}
public void setTempScale(String tempScale) {
this.tempScale = tempScale;
}
public void setTempSystem(double temp,String scale){
this.temp = temp;
this.tempScale = scale;
}
public String toString() {
return temp + " degree " + tempScale;
}
public boolean greaters(Thermometer therm) {
boolean isGreater = false;
if(this.tempScale.equals(therm.tempScale)){
if(this.temp > therm.temp){
isGreater = true;
}
}else if(this.tempScale.equals("C")&& therm.getTempScale().equals("F")){
double therm1 = this.temp;
double therm2 = (therm.getTemp() - 32.0) * (5.0/9.0);
if(therm1 > therm2){
isGreater = true;
}
}else if(this.tempScale.equals("F")&& therm.getTempScale().equals("C")){
double therm1 = this.temp;
double therm2 = (therm.getTemp() * (9.0/5.0))+ 32.0;
if(therm1 > therm2){
isGreater = true;
}
}
return isGreater;
}
public boolean lessers(Thermometer therm) {
boolean isLesser = false;
if(this.tempScale.equals(therm.tempScale)){
if(this.temp < therm.temp){
isLesser = true;
}
}else if(this.tempScale.equals("C")&& therm.getTempScale().equals("F")){
double temp1 = this.temp;
double temp2 = (therm.getTemp() - 32.0) *(5.0/9.0);
if(temp1 < temp2){
isLesser = true;
}
}else if(this.tempScale.equals("F")&& therm.getTempScale().equals("C")){
double temp1 = this.temp;
double temp2 = (therm.getTemp() *(9.0/5.0))+ 32.0;
if(temp1 < temp2){
isLesser = true;
}
}
return isLesser;
}
public boolean equals(Thermometer therm) {
boolean isEquals = false;
if(this.tempScale.equals(therm.tempScale)){
if(this.temp == therm.temp){
isEquals = true;
}
}else if(this.tempScale.equals("C")&& therm.getTempScale().equals("F")){
double temp1 = this.temp;
double temp2 = convertC(therm.getTemp());
if(temp1 == temp2){
isEquals = true;
}
}else if(this.tempScale.equals("F")&& therm.getTempScale().equals("C")){
double temp1 = this.temp;
double temp2 = convertF(therm.getTemp());
if(temp1 == temp2){
isEquals = true;
}
}
return isEquals;
}
public static double convertC(double cel){
double temp2 = (cel - 32.0) *(5.0/9.0);
return temp2;
}
public static double convertF(double far){
double temp2 = (far *(9.0/5.0))+ 32.0;
return temp2;
}
}
heres the demo program that it has to work with
/*CIT111
TemperatureDemo.java*/
import java.util.Scanner;
public class ThermometerDemo{
public static void main(String[] args)
{
// testing all constructors of Thermometer class and accessor and toString methods
Thermometer therm1 = new Thermometer();
System.out.println("Therm1 should be 0 degrees Celsius: " + therm1.toString() );
System.out.println("Therm1 test of accessor methods: " + therm1.getTemp() + " " + therm1.getTempScale());
Thermometer therm2 = new Thermometer(-40, "C");
System.out.println("Therm2 should be -40 degrees Celsius: " + therm2.toString() );
System.out.println("Therm2 test of accessor methods: " + therm2.getTemp() + " " + therm2.getTempScale());
// testing of equals method when both thermometers have the same scale C
if (therm1.equals(therm2)) //is therm2 (-40C) = therm1 (0C)? (FALSE)
System.out.println("ERROR: equals method reporting true when using C scale");
else
System.out.println("OK: equals method reporting false when therm1 = 0 C and therm2 = -40 C");
// testing of lessers method when both thermometers have the same scale C
if (therm2.lessers(therm1)) //is therm1 (0C) < therm2 (-40C) (FALSE)
System.out.println("ERROR: lessers method reporting true when using C scale");
else
System.out.println("OK: lessers method reporting false when using C scale");
// testing of greaters method when both thermometers have the same scale C
if (therm2.greaters(therm1)) //is therm1 (0C) > therm2 (-40C) (TRUE)
System.out.println("OK: greaters method reporting true when using C scale");
else
System.out.println("ERROR: greaters method reporting false when using C scale");
// testing of mutator methods -- change to two Fahrenheit values
therm1.setTemp(32.0);
therm1.setScale("F");
System.out.println(therm1.toString());
therm2.setTempSystem(0.0, "F");
System.out.println(therm2.toString());
// testing of equals method when both thermometers have the same scale F
if (therm1.equals(therm2)) //is therm2 (0F) = therm 1 (32F)? (FALSE)
System.out.println("ERROR: equals method reporting true when using F scale");
else
System.out.println("OK: equals method reporting false when using F scale");
// testing of lessers method when both thermometers have the same scale F
if (therm1.lessers(therm2)) //is therm2 (0F) < therm1 (32F)? (TRUE)
System.out.println("OK: lessers method reporting true when using F scale");
else
System.out.println("ERROR: lessers method reporting false when using F scale");
// testing of greaters method when both thermometers have the same scale F
if (therm2.greaters(therm1)) // is therm2 (0F) > therm1 (32F)? (FALSE)
System.out.println("OK: greaters method reporting true when using F scale");
else
System.out.println("ERROR: greaters method reporting false when using F scale");
// testing equivalent temperature values using different temperature scales
therm1.setTempSystem(0.0, "C");
therm2.setTempSystem(32.0, "F");
boolean result = therm1.equals(therm2);
System.out.println("0.0C = 32.0F (True) = " + result); //should be true
therm1.setTempSystem(-40.0, "F");
therm2.setTempSystem(-40.0, "C");
result = therm1.equals(therm2);
System.out.println("-40.0C = -40.0F (True) = " + result);
therm1.setTempSystem(100.0, "C");
therm2.setTempSystem(212.0, "F");
result = therm1.equals(therm2);
System.out.println("100.0C = 212.0F (True) = " + result);
// testing of public static methods to convert temperatures
System.out.println("Result of static method should be 0C: " + Thermometer.convertC(32.0));
System.out.println("Result of static method should be 32FC: " + Thermometer.convertF(0.0));
}
}