*(同樣這個問題的假設重複並不真正幫助我) 我想編譯這個相當簡單的程序,它顯示並移動一個足跡來演示運動。這是我與現在的工作:(Java)編譯時出現實例變量時出錯
// Represents a foot, used for displaying walking creatures.
import java.awt.Image;
import java.awt.Graphics;
public class Foot
{
private Image picture;
private CoordinateSystem coordinates;
// Constructor
public Foot(int x, int y, Image pic)
{
picture = pic;
coordinates = new CoordinateSystem(x, y, pic);
}
// Moves this foot forward by distance pixels
// (or backward if distance < 0).
public void moveForward(int distance)
{
coordinates.shift(distance, 0);
}
// Moves this foot sideways by distance pixels
// (to the right if distance > 0 or to the left
// if distance < 0).
public void moveSideways(int distance)
{
coordinates.shift(0, distance);
}
// Turns this foot (clockwise for degrees > 0).
public void turn(int degrees)
{
coordinates.rotate(Math.PI * degrees/180.0);
}
// Draws this foot in the appropriate coordinate system.
public void draw(Graphics g)
{
coordinates.drawImage(g, picture);
}
}
然而,當我試圖編譯程序我得到的錯誤:
cannot find symbol
private CoordinateSystem coordinates;
^
symbol: class CoordinateSystem
location: class Foot
Foot.java:15: error: cannot find symbol
coordinates = new CoordinateSystem(x, y, pic);
^
symbol: class CoordinateSystem
location: class Foot
2 errors
我相信,這是一個簡單的解決,但我是新來的Java和解釋爲什麼我得到這個錯誤消息將不勝感激。
這是一個重複的問題並沒有真正幫助我理解爲什麼我得到這個錯誤。有人會介意給我一個更具體的解釋嗎? –