Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2011
    Location
    Shouldn't be too hard to guess
    Posts
    3
    Rep Power
    0

    Question StandfordU CS106a free version - assignment 1

    Hi,

    I'm doing the Standford CS106A class free version. On assignment 1 number 3, my karel robot is fine on even checkboards, but stops at the third line on uneven checkboards. I've someone bring back his karel to the front of the line every time, but I just can't see why my program won't make it turn north and go on after the third line. 2 I would have an idea. 3 - really, why won't the little guy turn north!

    Thanks for your help. I never programmed before last week.

    SaraInMontreal


    Java Code:
    public void run(){
    	evenWorld();
    	turnNorth();
    	while (frontIsClear()){
    		checkboard();
    		turnNorth();
    	}	
    }
    	
    	/* for situation in even and uneven world that I could think of and that can happen at the end of the row*/
    	
    	private void checkboard(){
    		
    		if (noBeepersPresent() && leftIsClear()){
    			move(); 
    			turnLeft();
    			evenWorld();
    		}
    		
    		if (noBeepersPresent() && leftIsBlocked()){
    			move();
    			turnRight();
    			evenWorld();
    		}
    		
    		if (beepersPresent() && leftIsClear()){
    			move();
    			turnLeft();
    			unEvenWorld();
    		}
    		
    		if (beepersPresent() && leftIsBlocked()){
    			move();
    			turnRight();
    			unEvenWorld();
    		}
    	}
    	
    	/* to go on next top row*/
    	
    	private void turnNorth(){
    		if (notFacingNorth()){
    			turnLeft();
    		}
    		if (notFacingNorth()){
    			turnAround();
    		}
    	}
    	
    	/*every row in even world, every other row in uneven world*/
    	
    	private void evenWorld(){
    		putBeeper();
    		while (frontIsClear()){
    			move();
    			if (frontIsClear()){
    				move();
    				putBeeper();
    			}
    		}
    	}
    	
    	/*every other row in an uneven world*/
    	
    	private void unEvenWorld(){
    		while (frontIsClear()){
    			move();
    			putBeeper();
    			if (frontIsClear()){
    				move();
    			}
    		}
    	}

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: StandfordU CS106a free version - assignment 1

    Quote Originally Posted by SaraInMontreal View Post
    Java Code:
    	private void unEvenWorld(){
    		while (frontIsClear()){
    			move();
    			putBeeper();
    			if (frontIsClear()){
    				move();
    			}
    		}
    	}
    What is the if statement for. Remove it and the code will run regardless of how many rows there are.

  3. #3
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default Re: StandfordU CS106a free version - assignment 1

    Its highly unlikely anybody is familiar with Karel. Or willing to research it. I suggest searching the forum for a similar question. I have a feeling others have done this course.

  4. #4
    Join Date
    Dec 2011
    Location
    Shouldn't be too hard to guess
    Posts
    3
    Rep Power
    0

    Default Re: StandfordU CS106a free version - assignment 1

    Quote Originally Posted by Junky View Post
    What is the if statement for. Remove it and the code will run regardless of how many rows there are.
    I tried, it did not make a checkeredboard, but it did not stop at third line. I might be onto something. But what? I need to learn the frame of mind I think.

  5. #5
    Join Date
    Dec 2011
    Location
    Shouldn't be too hard to guess
    Posts
    3
    Rep Power
    0

    Default Re: StandfordU CS106a free version - assignment 1

    I know, it's really specific, but I did not find any forum I was allowed in specifically on this. It will be normal java sometime soon, if I can get through this.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: StandfordU CS106a free version - assignment 1

    Moderator action: Deleted full code solution (without code tags). Closing this thread.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Breakout Assignment from CS106a
    By tech8462 in forum New To Java
    Replies: 13
    Last Post: 10-09-2011, 03:38 AM
  2. Replies: 0
    Last Post: 10-26-2010, 07:53 AM
  3. QuickTable 2.0.5.31 (free version)
    By newbiejava in forum New To Java
    Replies: 4
    Last Post: 07-27-2010, 04:24 AM
  4. Redchery - Free Beta Version
    By robertflorish in forum Reviews / Advertising
    Replies: 0
    Last Post: 07-09-2010, 09:23 AM
  5. Debugger in JCreator Free Version
    By JordashTalon in forum JCreator
    Replies: 0
    Last Post: 01-28-2009, 10:10 PM

Tags for this Thread

Posting Permissions

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