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.

Results 1 to 4 of 4

Thread: Hold feature on Fruit Machine

  1. #1
    Member
    Join Date
    Feb 2012
    Posts
    39
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Hold feature on Fruit Machine

    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


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Hold feature on Fruit Machine

    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.

  3. #3
    Member
    Join Date
    Feb 2012
    Posts
    39
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Hold feature on Fruit Machine

    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?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hold feature on Fruit Machine

    the reel still spins.
    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.

    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.

Similar Threads

  1. any feature can do that?
    By keep smiling in forum AWT / Java Swing
    Replies: 1
    Last Post: May 14th, 2012, 10:44 AM
  2. Fruit machine, hold buttons.
    By LukeDavison in forum Object Oriented Programming
    Replies: 2
    Last Post: November 26th, 2011, 06:50 PM
  3. Moving MySql Database from one machine to another machine
    By vaishali in forum JDBC & Databases
    Replies: 5
    Last Post: July 21st, 2010, 01:21 AM
  4. Does this still hold true?
    By April in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: February 2nd, 2010, 09:28 AM
  5. New give thanks feature
    By JavaPF in forum The Cafe
    Replies: 0
    Last Post: April 11th, 2009, 11:14 AM