有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何修复我的等待时间方法

我的方法waitOut(seconds)被开发为等待一定的时间,直到它传递到插入其中的下一行代码

例如:

System.out.println("I am going to eat a cheeseburger");

waitOut(10); //<- 10 Seconds, that was converted in the method)

System.out.println("I took a bite of that cheeseburger");

这是课程

package Time;

import java.util.Timer;
import java.util.TimerTask;

/*
 * Developed for time passing of the game itself, doens't afflict with universal time
 */
 public class Timelapse {

     private static int timeInSeconds=0;
     private int timeInMinutes=0;
     private boolean day = true, night = false;
     private static Timer ourClock;
     private static TimerTask ourTask;

     public static void waitOut(int seconds) { // Method created for the time behind message print outs
        int num = seconds * 1000;
        ourClock = new Timer();
        ourTask = new Task();
        ourClock.scheduleAtFixedRate(ourTask,1000,1000);
    }   
}

共 (0) 个答案