You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your solution breaks on the SampleQuad2 map. Ive made a solution for this but not sure if it's the best way of doing it.
/*
* File: StoneMasonKarel.java
* --------------------------
* The StoneMasonKarel subclass as it appears here does nothing.
* When you finish writing it, it should solve the "repair the quad"
* problem from Assignment 1. In addition to editing the program,
* you should be sure to edit this comment so that it no longer
* indicates that the program does nothing.
*/
import stanford.karel.*;
public class StoneMasonKarel extends SuperKarel {
public void run() {
while(frontIsClear()) {
ColRepair();
nextCol();
for(int i = 0; i < 4; i++) {
move();
if(frontIsBlocked()) {
ColRepair();
nextCol();
}
}
}
}
private void ColRepair() {
turnLeft();
for(int i = 0; i < 4; i++) {
while(beepersPresent() && frontIsClear()) {
move();
if(!beepersPresent()) {
putBeeper();
}
}
beeperCheck();
}
}
private void beeperCheck() {
if(noBeepersPresent()) {
putBeeper();
if(frontIsClear()) {
move();
}
}
}
private void nextCol() {
turnAround();
while(frontIsClear()) {
move();
}
turnLeft();
}
}
The text was updated successfully, but these errors were encountered:
Your solution breaks on the SampleQuad2 map. Ive made a solution for this but not sure if it's the best way of doing it.
The text was updated successfully, but these errors were encountered: