How do I get the value of a Java object (GUI, animation, OOP)

I’m writing a lottery program in Java. Here are my classes:

Ball object

Main class

The issue is in the main class, line 33.

What I’m trying to do: First, I have the balls array that contains the 7 balls. When balls[i].getValue(); is called, I have a timer in the ball object that will be started, and a boolean flag spinning becomes true. Now some animation happens, basically the number starts shifting, but gradually slows down. When the delay reaches a certain number, the flag is set to false, and the timer is stopped. Now, back in getValue I tried some dumb stuff, like putting an empty loop that that keeps looping til the flag turns false (I know, I know…). I just can’t figure out a way to get that value.

Thanks for all your help!

Source: oop

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.