• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Repeating Countdown Timer

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 40
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Andreas L. Berg
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

>
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic