Here you can find the source of timeRemaining(double seconds)
Parameter | Description |
---|---|
seconds | number of seconds to loop |
public static boolean timeRemaining(double seconds)
//package com.java2s; /*/*from ww w. j a v a 2s . c o m*/ * Myro/Java license - GPL * * Myro/Java is a Java implementation of the Myro API, defined by the Institute for Robots in * Education (IPRE). See http://wiki.roboteducation.org for more information. * * Copyright 2010-2011 Douglas Harms dharms@depauw.edu * * This file is part of Myro/Java. * * Myro/Java is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * Myro/Java is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Myro/Java. If not, see <http://www.gnu.org/licenses/>. */ public class Main { private static boolean _newCountDown; private static long _startTime; /** * Controls a while-loop for a specific number of seconds. * * @param seconds number of seconds to loop * @return true iff the specified number of seconds has not elapsed */ public static boolean timeRemaining(double seconds) { if (_newCountDown) { _startTime = System.currentTimeMillis(); _newCountDown = false; } if (System.currentTimeMillis() <= _startTime + seconds * 1000) return true; else { _newCountDown = true; return false; } } }