Results 1 to 7 of 7

Thread: First of all...

  1. #1
    Tik
    Tik is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Smile First of all...

    Hello everybody,

    I'm new here and I thought why not say hello :)
    Ok now that that's out of the way... :cool:

    Can any of you please help me with this Karel/"Java" program I've made ==>


    /* This program collects a few beepers
    * which are scattered in karel world in the form of towers
    * name: beeperPickingKarel
    * date: 5 january 2009
    */

    import stanford.karel.*;

    public class beeperPickerKarel extends SuperKarel {

    public void run() {

    collectAllBeepers();
    dropAllBeepers();
    returnBack();
    }
    ----------------------------------------------------------------------------------> Line 18
    //This method defines the statements neccesary for Karel to collect all beepers
    private void collectAllBeepers() {

    while(frontIsClear()) {
    collectTheTowerOfBeepers();
    }
    collectTheTowerOfBeepers();
    }

    /* This method defines the statements neccesary for Karel to understand
    * the collectBeepers() method which contains the statements necessary for Karel->Line29
    * to collect the beepers
    */
    private void collectTheTowerOfBeepers() {

    faceTheTower();
    while(beepersPresent()) {
    pickBeeper();
    move();
    }
    faceTheGround();
    getBackDown();
    turnLeft();

    }

    //This method will let Karel face the tower(North)
    private void faceTheTower() {

    while(notFacingNorth()) {
    turnLeft();
    }

    }

    //This method lets Karel face the ground so he can get back to that direction
    private void faceTheGround() {

    while(notFacingSouth()) {
    turnRight();
    }

    }

    //This method get Karel back down
    private void getBackDown() {

    while(frontIsClear()) {
    move();
    }

    }

    //This method instruct Karel to drop all beepers that were collected
    private void dropAllBeepers() {

    while(beepersInBag()) {
    putBeeper();
    }

    }

    //This method gets Karel back to where he was in the beginning
    private void returnBack() {
    turnAround();
    while(frontIsClear()) {
    move();
    }
    turnAround();

    }

    }

    I tried to figure it out myself but it keeps saying:
    Severity and Description Path Resource Location Creation Time Id
    Syntax error, insert "}" to complete ClassBody Assignment1 CollectNewspaperKarel.java line 18 1231145885156 48

    Severity and Description Path Resource Location Creation Time Id
    Syntax error, insert "}" to complete MethodBody Assignment1 CollectNewspaperKarel.java line 29 1231145885156 49


    BTW:
    1. If you're wondering --> NO, I'm not a stanford student, I just happened to bump on Eric Robert's book on Karel The Robot.
    2. Sorry I couldn't get the indentation right... :(
    Can anybode please help?

    Thanks in advance....
    Last edited by Tik; 01-05-2009 at 11:46 AM. Reason: Question is asked

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Tik
    Tik is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default

    removing them doesn't help, if that is what you meant...

    thanks anyways...

  4. #4
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

  5. #5
    Tik
    Tik is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default

    Oh, ok.
    Thx, i have marked the lines with an arrow and turned the color to dark orange

    hope you can help me now....

  6. #6
    Tik
    Tik is offline Member
    Join Date
    Jan 2009
    Posts
    4
    Rep Power
    0

    Default

    I figured it out!
    Somehow Eclips was showing the errors of another program, after deleting that program the program worked without errors but there are still some logical problems :eek:

    But thanks anyways guys for your help! :)

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Please use code tags when you are posting again here. And also clearly state what your question, with the relevant code segment. Reading such a long code segment is mess for other members. Good luck!

Posting Permissions

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