私は初心者で、学校で CompSci のクラスを受講しています。この章ではサブクラスを作成しています。ただし、クラスが何らかの理由でプログラムを終了させています。世界も見えないし、エラーもない。(私はEclipseを実行しています)。
これが私のコードです:
package karel;
import kareltherobot.*;
public class Race implements Directions
{
public static void main(String args[]) {
class Car extends UrRobot
{ public Car(int street, int avenue, Direction direction, int beepers)
{super(5, 5, East, infinity);
}
public void turnAround()
{
turnLeft();
turnLeft();
}
public void turnRight()
{
turnLeft();
turnLeft();
turnLeft();
}
}
{
World.setVisible(true);
World.showSpeedControl(true);
}
{
Car kar = (Car) new UrRobot(5, 5, East, infinity);
kar.move();
kar.turnLeft();
kar.move();
kar.turnAround();
kar.move();
kar.turnRight();
}
}
}
このプログラムを終了までエラーにならないようにする方法はありますか?