Hi guys, after my "Calculator" was done with your help. I'm planning now to create a new program using Java a "Basketball, 24 shot clock timer" I can't imagine how to start or how I can make a Shot Clock Timer using Java. I need your best advice guys and what is the first step in making a shot clock timer. thanks in advance for helping me.:)

Recommended Answers

All 7 Replies

For those of us who know nothing of basketball, perhaps you can explain what a 24 shot timer is and how it works.
You may also find that the more precise your description is, the closer you will be to a software specification or design.

My guess is: you get 24 seconds to throw as much balls through the basket as possible, or you have to score 24 times, and time how long it takes the user.
you can use a thread to run your own timer, or continuesly compare the systemtime against the time when you started.
for the number of hits: just store in an integer and add 1 everytime the player scores.

or the other option, even simpler:
when you press start: store the current system time in a variable.
everytime you hit, you add 1 to a counter (which was 0 when you started)
when this counter reaches 24, end the game, get the (at that time) current system time.

the difference between these two times is your duration.

Sorry for that sir, I'm planning to create a program which is a 24seconds shot clock of basketball and it starts with 24seconds down to 23, 22, 21 until to 0, the condition is when the ball will hit into the ring the time will restart or back to 24secs again. Sorry for my grammar Sir I hope did you get my point..:(

OK then. JLabel with a big font for the numbers. Buttons for start/stop/reset. javax.swing.Timer set to fire every second (1000 mSec). Start the JLabel with 24, reduce it by 1 every time the timer fires

read here for more info
timer classes

thanks guys I really appreciate your kindness, I'll update you of what I have done my codes...

Member Avatar for hfx642

...and here I thought it was 30 seconds.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.