Hi,
I'm trying to write the code for a hold button on a fruit machine. Im not sure where to start or how to do it.
Can anyone help me please and point me in the right direction
Thank You
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi,
I'm trying to write the code for a hold button on a fruit machine. Im not sure where to start or how to do it.
Can anyone help me please and point me in the right direction
Thank You
Start out with a detailed description of a problem to be solved. "...trying to write the code for a hold button on a fruit machine..." is not very detailed and tells very little.
Once you have that, figure out a process to solve the problem without thinking about code.
From that point it will be easier to write the code to solve the problem.
i have given it a try but i dont understand why it wont work. I have set a timer for each real and when the hold button is selected the timer stops so that reel doesnt spin. However the reel still spins.
the code i have for the reels which seem to work fine are:
if(event.getSource()==btnStart){ counter = 0; timer1 = new Timer(50,this); timer1.start(); timer2 = new Timer(50,this); timer2.start(); timer3 = new Timer(50,this); timer3.start(); } if(event.getSource()==timer1) { setIcon1 (); } if(event.getSource()==timer2) { setIcon2 (); } if(event.getSource()==timer3) { setIcon3 (); } if(event.getSource()==timer1){ timer1.stop(); } if(event.getSource()==timer2){ timer2.stop(); } if(event.getSource()==timer3){ timer3.stop(); } } } public void stopTimer1(){ timer1.stop(); } public void stopTimer2(){ timer2.stop(); } public void stopTimer3(){ timer3.stop(); }
the code for hold button which doesnt work is:
if(event.getSource()== btnHoldLeft){ timer1.stop(); } if(event.getSource()== btnHoldMiddle){ timer2.stop(); } if(event.getSource()== btnHoldRight){ timer3.stop(); }
am i missing something in the coding for the hold buttons?
What variable(s) controls that action? Try debugging the code by adding println statements that print out the values of all the variables used when they are changed and used.the reel still spins.
Could you make a small complete program that compiles, executes and shows the problem?
If you don't understand my answer, don't ignore it, ask a question.