Stanford CS106A resources I
1) Text Book "The Art and Science of Java"
2) The book available in multiple format from the Author's site (Animated Slide & Code)
3) "Karel the Robot Learns Java" online version of one of the 'book' tutorial as recommended in the class.
The relevant part that might be required even after knowing Java.
Karel Reference Card
This appendix defines the structure of the Karel programming language on a single page.
Built-in Karel commands:
move();
turnLeft();
putBeeper();
pickBeeper();
Karel program structure:
/*
* Comments may be included anywhere in
* the program between a slash-star and
* the corresponding star-slash characters.
*/
import stanford.karel.*;
/* Definition of the new class */
public class name extends Karel {
public void run() {
statements in the body of the method
}
definitions of private methods
}
Karel condition names:
frontIsClear() frontIsBlocked()
leftIsClear() leftIsBlocked()
rightIsClear() rightIsBlocked()
beepersPresent() noBeepersPresent()
beepersInBag() noBeepersInBag()
facingNorth() notFacingNorth()
facingEast() notFacingEast()
facingSouth() notFacingSouth()
facingWest() notFacingWest()
Conditional statements:
if (condition) {
statements executed if condition is true
}
if (condition) {
statements executed if condition is true
} else {
statements executed if condition is false
}
Iterative statements:
for (int i = 0; i <>statements to be repeated
}
while (condition) {
statements to be repeated
}
Method definition:
private void name () {
statements in the method body
}
New commands in the SuperKarel class:
turnRight();
turnAround();
paintCorner(color);
New conditions in the SuperKarel class:
random()
random(p)
cornerColorIs(color)
Karel Colors
BLACK
BLUE
CYAN
DARK_GRAY
GRAY
GREEN
LIGHT_GRAY
MAGENTA
ORANGE
PINK
RED
WHITE
YELLOW
null
0 Comments:
Post a Comment
<< Home