File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Repeating Countdown Timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Repeating Countdown Timer" Watch "Repeating Countdown Timer" New topic
Author

Repeating Countdown Timer

Andreas L. Berg
Greenhorn

Joined: Oct 10, 2007
Posts: 8
Hi there,

my Girlfriend wants to do some exercises at home and asks me for an app for that ;o)
It should do simply "give me Time1 (e.g. 30Secs), Time 2 (40Secs.)and so on, after Time 1 get a system beep out and begin to count down Time2 and so on"
So as much i understand, not that complicated. Ok i googeld a bit for the Timer issue and the AudioOut (i did not do both before, im a real Greenhorn) and found at least waht i need (i guess).

Now i have put all of them together and it looks not that bad (i guess again ;o) )
For the Timer i want to use a Array, it seemed to be the easiest way but there a have a mistake and i don´t get what i did wrong.
Everything looks fine, just that the Array Slot wont count up in the for loop. Im hanging at there, can someone have a look on it and give me a hint please? (Eclipse don´t let me just write [j] it has to be timer[j]……)




ok ok i found it,
i had to do

and get the while loop out of it, makes no sense and breaks the process after the first run, but now the Timer don´t recognize the time…… ;o(
Andreas L. Berg
Greenhorn

Joined: Oct 10, 2007
Posts: 8
Me again,

after all i saw that calling the Array also Timer, is not that smart, so i changed that to and paste the changed code in here again.

Vijay Vishwa
Greenhorn

Joined: Nov 21, 2010
Posts: 28
Hi Andreas,
From you problem statement I understand that the time should be sequential i.e. Suppose 3 timers 10sec, 15sec, 28sec , ..
First time should count 10 sec. After 10 sec is done there is beep and next time should start and count 15sec.

Is this you want?

If this is the one, then I see that all the timers are starting at same time, i.e. there is overlap
Form the above example
All timers 10, 15, 20 start at same time
First beep is heard at 10, next at 5 sec and third at 3 sec.

The solution could be that the while creating the Reminder, add up the previous timer



Let me know if I interpreted it wrongly.

SCJP 5.0 OCBCD 5.0(Formerly SCBCD)
Andreas L. Berg
Greenhorn

Joined: Oct 10, 2007
Posts: 8
First time should count 10 sec. After 10 sec is done there is beep and next time should start and count 15sec.

Is this you want?


Yes, exactly thats what i (or better my Girlfriend) want ;o)

For better understanding, i paste the Code again. I really don't know if i understood right what you changed, but it has not the healing effect i hoped.
Maybe (as i said im really new to that stuff) i just don´t get the whole thing that is for others obvious. Sorry. But coul you explain.



upsi ;o)

i forget to integrate the line
"zeitSum = zeitSum + zeit[i];"

now it works, but i still dont know why……
Andreas L. Berg
Greenhorn

Joined: Oct 10, 2007
Posts: 8
Well…… i was proud, showed it my Girlfriend and where disappointed……

What she really wants is:

1. Tell the whole Time (lets say 12 Minutes)
2. Give me the first Time (e.g. 10 Seconds)
3. Give me the second Time (e.g. 30 Seconds)

after that

in duration of 12Minutes should be after 10 Secs a beep, then after 30 Secs, then 10, then30 and so on……… until the value of (here) 12 Minutes are reached.

And after this point im overstrained, if you Guys dont give me a hint how i should solve that riddle……
Andreas L. Berg
Greenhorn

Joined: Oct 10, 2007
Posts: 8
After all i tried and as much i could puzzle out you can see in the code down.
I assume im not as far from the solution away but i did not found the real clue yet.

>
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
don't know what all the scanner and println stuff is for, but to get just a beep every 10 then 30 seconds,
this is about all you'd need (will beep at 1,4,5,8,9,12,13 etc seconds - multiply by 10 where indicated to get 10,40,50,80 etc)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Repeating Countdown Timer
 
Similar Threads
Problem with the Scanner Class
Thread Question
Threads doubt
Set Timer
Help needed with java.util.Timer