I have a problem. I tried debugging and I saw nothing pop up. Something is wrong but I cant seem to find it since its not a syntax error. I rechecked everything and I still couldnt find the problem.
Here is what the code is supposed to do.
1) Take in the user's integer value.
2) Print the values as they count with 1 second interval.
3) When it reaches one a message pops up and says "Time's up!!".
However when i run it, it asks for input and pops up the message immediately. There is no printing of the countdown, nor is there any one second interval. I have two classes, the main class and a class with all the functions. They names will help you tell what they do from the start.
Here is the class with the functions.
package kitchentimer;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Timer {
boolean decide=false;
Scanner input = new Scanner(System.in);
public void getTime(int t){
System.out.println("Set the timer value in seconds");
t=input.nextInt();
}
public void runTimer (int tmrValue){
System.out.println("The timer has started");
tmrValue++;
for (int x=1; x<tmrValue{
System.out.println(tmrValue);
Thread.sleep(1000);
tmrValue-=1;
}
if(tmrValue==1){
decide=true;
}
}
public void timerEnd (){
if (decide==true){
JOptionPane.showMessageDialog(null,"Time is up!!");
}
}
}
Here is the main class
package kitchentimer;
public class KitchenTimer {
public static void main(String[] args) {
int TimeValue=0;
Timer TimerObject = new Timer();
TimerObject.getTime(TimeValue);
TimerObject.runTimer(TimeValue);
TimerObject.timerEnd();
}
}
Please help me find the problem so I can avoid it in the future.Timer.zipTimer.zip