Results 1 to 5 of 5
  1. #1
    marcos1 is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default CheckerBoardKarel - Stanford CS106A Assignment 1

    hello i need help im able to do most world presents but 7x7 and 1x8 etc
    i know i can google this and come up with 100,000's of resaults but i really want to learn and need direct pointers not answers on how to fix my algorithm so heres my code i tried to note it as much as posible please help
    Java Code:
    /*
     * File: CheckerboardKarel.java
     * ----------------------------
     * When you finish writing it, the CheckerboardKarel class should draw
     * a checkerboard using beepers, as described in Assignment 1. You
     * should make sure that your program works for all of the sample
     * worlds supplied in the starter folder.
     */
    
    import stanford.karel.*;
    
    public class CheckerboardKarel extends SuperKarel {
    
    	public void run() {
    		while(frontIsClear()){
    			makeCheckers();
    			moveUpWall();
    		}
    		turnRight();
    	}
    
    	private void makeCheckers(){ //this is where the script will make a checker pattern
    		if(noBeepersPresent()){ //here im checking wether their is a beeper a the begging of the world and then moves up one spot if posible
    			putBeeper();
    			if(frontIsClear()){
    				move();
    				while(frontIsClear()){ //this is the part where the script will put a beeper move put beeper
    					move();
    					if(noBeepersPresent()){ //here it checks if a beeper is present if not it puts a beeper
    						putBeeper();
    						if(frontIsClear()){
    							//here it moves up if the space is clear infront
    							move();
    						}
    					}
    				}
    			}
    		}
    	}
    
    private void moveUpWall(){
    	// here the script will turn left or right to face up depending on whether it's facing east or west
    	if(facingEast()){
    		turnLeft();
    		if(frontIsClear()){
    			move();
    			turnLeft();
    		}
    	} else {
    		if(facingWest()){
    			turnRight();
    			if(frontIsClear()){
    				move();
    				turnRight();
    			}
    		}
    	}
    }
    
    }
    also heres a github link of the entire project im tring

    https://github.com/marcos1/java_learning

  2. #2
    marcos1 is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default Re: CheckerBoardKarel - Stanford CS106A Assignment 1

    so far i have determined that the problem is in this while loop
    Java Code:
    			while(frontIsClear()){ //this is the part where the script will put a beeper move put beeper
    				move();
    				if(noBeepersPresent()){ //here it checks if a beeper is present if not it puts a beeper
    					putBeeper();
    					if(frontIsClear()){
    						//here it moves up if the space is clear infront
    						move();
    					}
    				}
    			}

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default Re: CheckerBoardKarel - Stanford CS106A Assignment 1

    Can you explain what the problem is? What does the code do and what do you want it to do different?
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    marcos1 is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Default Re: CheckerBoardKarel - Stanford CS106A Assignment 1

    Quote Originally Posted by Norm View Post
    Can you explain what the problem is? What does the code do and what do you want it to do different?
    it's supposed to make a checkerboard pattern on different sized worlds/patterns

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default Re: CheckerBoardKarel - Stanford CS106A Assignment 1

    What does it do now?
    I don't use or know the stanford packages
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 11
    Last Post: 05-12-2013, 06:20 PM
  2. Stanford CS106a breakout assignment
    By Newbieprogrammer in forum New To Java
    Replies: 3
    Last Post: 08-14-2012, 10:18 AM
  3. Stanford CS106a GraphicsHeirarchy
    By Newbieprogrammer in forum New To Java
    Replies: 0
    Last Post: 07-15-2012, 07:37 PM
  4. CheckerBoardKarel - Stanford CS106A Assignment 1
    By mattdotmac in forum New To Java
    Replies: 6
    Last Post: 07-15-2012, 01:58 PM
  5. Stanford cs106a
    By D.good in forum Introductions
    Replies: 1
    Last Post: 02-04-2012, 06:18 PM

Posting Permissions

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