CSBridge Darafaka Lisesi. 2014 Boazii nv. 2015 Ko nv. 2016 Ko - - PowerPoint PPT Presentation
CSBridge Darafaka Lisesi. 2014 Boazii nv. 2015 Ko nv. 2016 Ko - - PowerPoint PPT Presentation
CSBridge Darafaka Lisesi. 2014 Boazii nv. 2015 Ko nv. 2016 Ko nv. 2017 CTU, Czech Republic + Ko nv. 2018 Bryce Julia Asena Nick Chris Ou Our awesome 2019 2019 Ko Ko te teaching te team! Bar Pelin
Boğaziçi Ünv. 2015 Darüşşafaka
- Lisesi. 2014
Koç Ünv. 2016 Koç Ünv. 2017 CTU, Czech Republic + Koç Ünv. 2018
Asena Bryce Julia Nick Chris
Ou Our awesome 2019 2019 Ko Koç te teaching te team!
Pelin Barış
Logistics
LOL: Lots of Labs!
Labrador Retrievers (Labs)
(computer)
Logistics
Discussion Section
Meet your friends and talk through problems with your Section Leader!
Stanford?
Stanford
Prerequisites
http://koc.csbridge.org Course Website
*note that its or
- rg, not co
com
Very High Level Journey
Breakout
What if I fall behind?
CS Bridge
Share Ideas Not Code
Questions?
Our First Step
Karel
s
Karel Speaks Java
+ + + + + + + + + + + + + + + 1 2 3 1 2 3 4 5
North South West East
Karel’s World
+ + + + + + + + + + + + 1 2 3 1 2 3 4
Walls
Beepers
+ + + + + + + + + + + + 1 2 3 1 2 3 4
Knows Four Commands move(); turnLeft(); pickBeeper(); putBeeper();
move();
move();
+ + + + + + + + + + + + 1 2 3 1 2 3 4
move();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
turnLeft();
turnLeft();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
turnLeft();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
pickBeeper();
pickBeeper();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
pickBeeper();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
putBeeper();
putBeeper();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
putBeeper();
+ + + + + + + + + + + + 1 2 3 1 2 3 4 +
Questions?
+ + + + + + + + + + + + 1 2 3 1 2 3 4
First Challenge
+ + + + + + + + + + + + 1 2 3 1 2 3 4
First Challenge
First Challenge
move(); turnLeft(); pickBeeper(); putBeeper();
Need a Volunteer
First Challenge
move(); turnLeft(); pickBeeper(); putBeeper();
Let’s Try It
StepUp.java
Questions?
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnLeft(); turnLeft(); turnLeft(); move(); putBeeper(); move(); } }
Improving our Program
It’s “Turn Right”, but… 🙂 not very clear 😪 tedious
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); // turns Karel right turnLeft(); turnLeft(); turnLeft(); move(); putBeeper(); move(); } }
Improving our Program
It’s “Turn Right”, but… descriptive comments 😪 tedious
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); // turns Karel right turnLeft(); turnLeft(); turnLeft(); move(); putBeeper(); move(); } }
Anatomy of a Program
This is the program's so sour urce e code de
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); // turns Karel right turnLeft(); turnLeft(); turnLeft(); move(); putBeeper(); move(); } }
Anatomy of a Program
This piece of the program’s so sour urce e code de is called a me method.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); // turns Karel right turnLeft(); turnLeft(); turnLeft(); move(); putBeeper(); move(); } }
Anatomy of a Program
This word is the nam name of
- ur me
method (here, run)
We must always have a run() method to run our program. But we can make an any
- th
- ther
er m meth thod
- ds w
s we w e want!
Method Definition
private void name() { statements in the method body }
T h i s a d d s a n e w c
- m
m a n d t
- K
a r e l ’ s v
- c
a b u l a r y
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Improving our Program
Define a turnRight me method Ca Call our turnRight me method
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program
This is called an im import statement. It tells Java what Karel is.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Anatomy of a Program
This is called a co code block.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Program Style
These are terrifying!
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Program Style
St Style Ti Tip #1: Align braces in your code blocks.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Program Style
St Style Ti Tip #1: Align braces in your code blocks.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Program Style
St Style Ti Tip #1: Align braces in your code blocks.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Program Style
St Style Ti Tip #2: Align indentation in your code blocks.
import stanford.karel.*; public class StepUp extends Karel { public void run() { move(); pickBeeper(); turnLeft(); move(); turnRight(); move(); putBeeper(); move(); } private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } }
Program Style
St Style Ti Tip #2: Align indentation in your code blocks.