您好,我正在为学校做一个项目,我很难弄清楚为什么我的程序一直告诉我我在所有方法中都缺少返回语句,
这是我的代码:
public class Temperature {
private int temperature;
//constructors
public int Test( int temperature )
{
temperature = temperature;
return temperature;
}
public int TempClass()
{
temperature = 0;
return 0;
}
// get and set methods
public int getTemp()
{
return temperature;
}
public void setTemp(int temp)
{
temperature = temp;
}
//methods to determine if the substances
// will freeze or boil
public static boolean isEthylFreezing(int temp)
{
int EthylF = -173;
if (EthylF <= temp)
{System.out.print("Ethyl will freeze at that temperature");}
else
return false;
}
public boolean isEthylBoiling(int temp)
{
int EthylB = 172;
if (EthylB >= temp)
System.out.print("Ethyl will boil at that temperature");
else
return false;
}
public boolean isOxygenFreezing(int temp)
{
int OxyF = -362;
if (OxyF <= temp)
System.out.print("Oxygen will freeze at that temperature");
else
return false;
}
public boolean isOxygenBoiling(int temp)
{
int OxyB = -306;
if (OxyB >= temp)
System.out.print("Oxygen will boil at that temperature");
else
return false;
}
public boolean isWaterFreezing(int temp)
{
int H2OF = 32;
if (H2OF <= temp)
System.out.print("Water will freeze at that temperature");
else
return false;
}
public boolean isWaterBoiling(int temp)
{
int H2OB = 212;
if (H2OB >= temp)
System.out.print("Water will boil at that temperature");
else
return false;
}
}