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 5 of 5

Thread: help fix this code

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    19
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default help fix this code

    g
    Last edited by dmanmeds; June 23rd, 2014 at 07:10 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,147
    Thanks
    48
    Thanked 2,158 Times in 2,131 Posts

    Default Re: help fix this code

    How can the code be compiled and executed for testing? There are missing classes.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    19
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: help fix this code

    I forgot to change the class name, sorry I fixed that part now. I was having really hard trouble doing all three at once so I started by scratch but only with one dog and once I got one dog running well, I put the other dogs in.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,147
    Thanks
    48
    Thanked 2,158 Times in 2,131 Posts

    Default Re: help fix this code

    The code needs formatting to make it easier to read.
    Several } are hidden at end of a line. }s should be on a line by itself
    Statement(s) after an if and for statement should be enclosed in {}s.
    Statements after if hidden on same line vs in {}s on a new line
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,147
    Thanks
    48
    Thanked 2,158 Times in 2,131 Posts

    Default Re: help fix this code

    This is NOT good style:
     if(fido >=(track-1)) fido = (track-1);  //<<<<<<<< HIDDEN statement
    // it should be on two lines:
     if(fido >=(track-1)) {
        fido = (track-1);
     }

    Also there any many for statements with missing {}s
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Need help to fix my code
    By Nathanlll in forum What's Wrong With My Code?
    Replies: 5
    Last Post: September 18th, 2013, 09:32 AM
  2. Replies: 3
    Last Post: April 27th, 2013, 07:19 AM
  3. How do i fix my code?
    By beebee007 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 14th, 2012, 10:49 AM
  4. Help me to fix this code
    By rcbandit2 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 31st, 2011, 01:30 PM
  5. How to fix this code?
    By ice in forum AWT / Java Swing
    Replies: 26
    Last Post: November 29th, 2010, 06:10 PM