-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoneMasonKarel.java
More file actions
58 lines (52 loc) · 1.04 KB
/
StoneMasonKarel.java
File metadata and controls
58 lines (52 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* 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 {
// You fill in this part
public void run() {
while(frontIsClear()) {
turnLeft();
fillColumn();
turnLeft();
goToNextColumn();
}
turnLeft();
fillColumn();
turnLeft();
}
public void fillColumn() {
scaleColumn();
turnAround();
completeColumn();
}
public void scaleColumn() {
while(frontIsClear()) {
move();
}
}
public void completeColumn() {
while(frontIsClear()){
if(noBeepersPresent()){
putBeeper();
}
move();
}
if(noBeepersPresent()){
putBeeper();
}
}
public void goToNextColumn()
{
for(int i = 0; i < 4; i++)
{
move();
}
}
}