首先,我有三门课。一个叫:
温度(超类)
天气(子类超类)
UseTemperature(包含 main 方法的子类)
对于这个程序,主要方法应该只显示摄氏温度和风速。虽然不知道是什么问题。。
我的问题是在 UseTemperature 中找不到 setWindSpeed/getWindSpeed。
//TEMPERATURE:
public class Temperature
{
private double degrees;
public void setDegrees (double degrees)
{
this.degrees = degrees;
}
public double getDegrees ()
{
return degrees;
}
/////////////////////////////////////////////////////////////////////////////////////////
//WEATHER:
public class Weather extends Temperature
{
private double windspeed; // Number + km/h
private void setWindSpeed (double windspeed) //setter
{
this.windspeed = windspeed;
}
public double getWindSpeed () //getter
{
return windspeed;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
//USE TEMPERATURE:
class UseTemperature // can be public but makes no diffrence
{
public static void main (String args[])
{
Temperature temp;
temp = new Temperature ();
temp.setDegrees (40.0);
temp.setWindSpeed (70.0); // NOT FOUND IN TEMPERATURE
System.out.print (temp.getDegrees ());
System.out.print (" degrees ");
System.out.println (temp.getWindSpeed()); // NOT FOUND IN TEMPERATURE
System.out.println (" km/h");
}
}