Java ウィンドウで電車を動かそうとしていますが、深刻な問題が発生しています。電車を作ったTrainクラスと、電車を動かすことになっているDriverクラスがあります。画面の左端を「通過」するまで、列車全体を右から左に移動させる必要があります。次に、if ステートメントを追加して dx を変更し、列車が右側で再始動するようにします。以下は私が試したものですが、うまくいきません。誰でも私を助けてもらえますか??
public class Driver extends GraphicsProgram
{
//~ Instance/static variables .............................................
private static final int N_STEPS = 1000;
private static final int PAUSE_TIME = 20;
private static final double TRAIN_LENGTH = 320;
//~ Constructor ...........................................................
// ----------------------------------------------------------
/**
* The run() method of the Driver Class.
* Creates an instance of the Train Class.
* Responsible for animating the train across the screen.
*/
public void run()
{
Train train = new Train(getGCanvas());
for (int i = 0; i < N_STEPS; i++) {
train.move(-100, 0);
pause(PAUSE_TIME);
}