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
No comments:
Post a Comment