Results 1 to 2 of 2

Thread: Urgent Help - Else Without If

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2003
    Posts
    140

    Urgent Help - Else Without If

    Code:
        {   if (robot.getHeading() == IRobot.NORTH)
                northController(robot);
                robot.face(northController(robot));
            else if (robot.getHeading() == IRobot.EAST)
                eastController(robot);
                robot.face(eastController(robot));
            else if (robot.getHeading() == IRobot.SOUTH)
                southController(robot);
                robot.face(southController(robot));
            else if (robot.getHeading() == IRobot.WEST)
                westController(robot);
                robot.face(westController(robot));
        }
    I keep getting else without if errors and there are 3 of them which point at the three elses!

    Any ideas how to fix the problem please?

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552

    Re: Urgent Help - Else Without If

    Code:
        {   if (robot.getHeading() == IRobot.NORTH){
                northController(robot);
                robot.face(northController(robot));
            }
            else if (robot.getHeading() == IRobot.EAST){
                eastController(robot);
                robot.face(eastController(robot));
            }
            else if (robot.getHeading() == IRobot.SOUTH){
                southController(robot);
                robot.face(southController(robot));
            }
            else if (robot.getHeading() == IRobot.WEST){
                westController(robot);
                robot.face(westController(robot));
            }
        }
    ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width