Bo ğ aziçi Ünv. 2015 Darü şş afaka Lisesi. 2014 Koç Ünv. 2016 Koç Ünv. 2017
Asena Bryce Julia
Nick Chris Lisa
Great team!
Pelin Barı ş Yazar
Logistics
Stanford?
Stanford
Prerequisites
Course Website http://koc.csbridge.org *note that its org not com
Very High Level
Breakout
What if I fall behind?
Share Ideas Not Code
Karel Speaks Java s
Karel’s World North 3 + + + + + West East + + + + + 2 + + + + + 1 South 1 2 3 4 5
Knows Four Commands move(); turnLeft(); putBeeper(); pickBeeper();
Walls 3 + + + + 2 + + + + 1 + + + + 1 2 3 4
Beepers 3 + + + + 2 + + + + 1 + + + + 1 2 3 4
move();
move(); 3 + + + + 2 + + + + 1 + + + + 1 2 3 4
move(); 3 + + + + 2 + + + + 1 + + + + + 1 2 3 4
turnLeft();
turnLeft(); 3 + + + + 2 + + + + 1 + + + + + 1 2 3 4
turnLeft(); 3 + + + + 2 + + + + 1 + + + + + 1 2 3 4
pickBeeper();
pickBeeper(); 3 + + + + 2 + + + + 1 + + + + + 1 2 3 4
pickBeeper(); 3 + + + + 2 + + + + 1 + + + + + 1 2 3 4
Questions?
First Challenge 3 + + + + 2 + + + + 1 + + + + 1 2 3 4
First Challenge 3 + + + + 2 + + + + 1 + + + + 1 2 3 4
Need a Volunteer
Lets Try It
Program Style
Questions?
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); turnLeft(); move(); turnRight(); This is the program's move(); source code putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); turnLeft(); This piece of the program's move(); source code is called a method . turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); This line of code gives the turnLeft(); name of the method move(); (here, run) turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); This line of code gives the turnLeft(); name of the method move(); (here, turnRight) turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); turnLeft(); move(); This is called an import statement . It turnRight(); move(); tells Java what Karel is. putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); This is called a turnLeft(); code block move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Method Definition private void name () { statements in the method body }
Program Style import stanford.karel.*; public class OurKarelProgram extends Karel { public void run() { move(); pickBeeper(); move(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Place 100 beeper?
For Loop for (int i = 0; i < N ; i++) { // to repeat N times }
Review for (int i = 0; i < N ; i++) { // to repeat N times }
Work in Any World Before After After Before
Don’t Know World Size ?
Recommend
More recommend