I'm doing a game in which you have to calculate the time in seconds that is requested by keyboard, and when that time exceeds the end of the game. But when it goes through that if
, it does not calculate time or it's infinite or it just lets you play a round.
I leave the code:
public static void main(String[] args) {
long tiempoini, tiempofin;
Instrucciones num;
boolean seguimos ;
Instrucciones.pedirTiempoYCantidad();
do {
tiempoini = System.currentTimeMillis() / 1000;
num = new Instrucciones();
long y = tiempoini + num.getTiempoJue();
tiempofin = System.currentTimeMillis() / 1000;
if (tiempofin< y) {
if(num.getCant()==0){
System.out.println("Has acertado las " + num.getCantOperaciones() + " operaciones.Has ganado!!");
seguimos=false;
}else{
seguimos=true;
}
}else{
System.out.println("LO SIENTO, SE HA ACABADO EL TIEMPO PARA REALIZAR MAS OPERACIONES.");
seguimos=false;
}
} while (seguimos);
if (num.getCant() != 0) {
System.out.println("Lo siento, no ha acertado " + num.getCantOperaciones() + " operaciones.Has perdido!!");
}
}
}