GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Jan-2009, 23:37
newprogrammer newprogrammer is offline
New Member
 
Join Date: Jan 2009
Posts: 1
newprogrammer is on a distinguished road

Karel checker board problem


im doing this online stanford engineering class that's using karel the robot to teach programming basics. karel lives in a grid where he can put, and pick up beepers, move, turn left, and turn right. I have to turn a grid of any dimensions into a checker board by placing beepers in a checker board pattern. I made this program and it works but he ends up running into the wall at the end. can anybody help me fix this? here's the program:

JAVA Code:
import stanford.karel.*;

public class CheckerboardKarel extends SuperKarel {

	public void run() {
		moveQuick();
	}
	
	private void moveQuick() {
		putBeeper();
		moveNow();
		moveNow();
		moveQuick();
	}
	
	private void moveNow() {
		if(frontIsClear()) {
			move();
		} else {
			if(facingEast()) {
				turnLeft(); 
				move();
				turnLeft();
			} else {
				turnRight();
				move();
				turnRight();
				
			}
		}
	}

	
}
Last edited by admin : 13-Jan-2009 at 23:46. Reason: Please insert your example Java codes between [JAVA] and [/JAVA] tags
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Torrents Download Problem chandeep Computer Software Forum - Linux 7 09-Oct-2006 23:37
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 13:31
Runtime Problem involving "printf" in C Program supamakia C Programming Language 2 09-Oct-2005 11:09
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 08:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:08.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.