Writen by Chris Piech
Handouts:
KarelReference
Worked Examples:
Invert,
UN Karel
Day1: RandomPainter.java
Karel is starting to find her world too black and white. Help her fill it with color.
Karel has a few commands up her sleeve. She can paint the corner on which she is standing using the instruction
paintCorner(color);
Karel also defines a new condition random, which is true half the time, but in an unpredictable way. Like flipping a coin, sometimes it is true and sometimes it is false. For example the code
if(random()) {
putBeeper();
}
Use these new abilities to have karel randomly paint each corner of a world one of two colors. You can chose any two colors you would like; we chose green and blue.
Below are three executions of the same program that randomly paints any sized world green and blue executed on a 10x10 world. Note that because of the random condition, the pattern of green and blue is different on each run!
As always, remember to decompose your solution! Your program should work on a world of any size.