SlideShare a Scribd company logo
Introduction to Programming
Class 4
Paul Brebner
Housekeeping
• The Programming course shared directory is
located at XXX. I’ll update this with information,
sub directories are:
– Exercises
– Lessons
– Textbook
– Students
• The processing environment has a shortcut on
desktops, so you won’t need to reinstall it again.
Repetition (of repetition!)
• What does this program do?
println(“1”);
println(“2”);
println(“3”);
println(“4”);
println(“5”);
println(“Once I caught a fish alive”);
println(“6”);
println(“7”);
println(“8”);
println(“9”);
println(“10”);
println(“Then I let it go again (etc)”);
Repetition (of repetition!)
• This
1
2
3
4
5
Once I caught a fish alive
6
7
8
9
10
Then I let it go again (etc)
Using a while loop
with 2 bugs
int number = 1; // start from 1
while (number <= 10) // while number <= 10 repeat the block
{ // a block – do everything between { and }
println(number); // print the number each time
println(“Once I caught a fish alive”);
println(“Then I let it go again (etc)”);
}
Repetition (of repetition!)
1
Once I caught a fish alive
Then I let it go again (etc)
1
Once I caught a fish alive
Then I let it go again (etc)
1
Once I caught a fish alive
Then I let it go again (etc)
1
Once I caught a fish alive
Then I let it go again (etc)
1
Once I caught a fish alive
Then I let it go again (etc)
...
Using a while loop
int number = 1; // start from 1
while (number <= 10) // while number <= 10 repeat the block
{ // a block – do everything between { and }
println(number); // print the number each time
println(“Once I caught a fish alive”);
println(“Then I let it go again (etc)”);
number = number + 1; // must increment number by 1 each time
}
Better - slightly
1
Once I caught a fish alive
Then I let it go again (etc)
2
Once I caught a fish alive
Then I let it go again (etc)
3
Once I caught a fish alive
Then I let it go again (etc)
4
Once I caught a fish alive
Then I let it go again (etc)
5
Once I caught a fish alive
Then I let it go again (etc)
...
10
Once I caught a fish alive
Then I let it go again (etc)
Using a while loop
and an if
int number = 1; // start from 1
while (number <= 10) // while number <= 10 repeat the block
{ // a block – do everything between { and }
println(number); // print the number each time
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
println(“Then I let it go again (etc)”);
number = number + 1; // must increment number by 1 each time
}
Correct
1
2
3
4
5
Once I caught a fish alive
6
7
8
9
10
Then I let it go again (etc)
for loop
this while loop is identical to for loop
int number = 1; // start from 1
while (number <= 10) // while number <= 10 repeat the block
{ // a block – do everything between { and }
println(number); // print the number each time
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
println(“Then I let it go again (etc)”);
number = number + 1; // must increment number by 1 each time
}
for loop
// start from 1
// while number <= 10 repeat the block
// at end increment number by 1 and repeat
for (int number = 1; number <= 10; number = number + 1)
{
println(number);
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
println(“Then I let it go again (etc)”);
}
comparison
// while loop
int number = 1; // start from 1
while (number <= 10) // while number <= 10 repeat the block
{ // a block – do everything between { and }
println(number); // print the number each time
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
println(“Then I let it go again (etc)”);
number = number + 1; // must increment number by 1 each time
}
// for loop
for (int number = 1; number <= 10; number = number + 1)
{
println(number);
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
println(“Then I let it go again (etc)”);
}
number++
// start from 1
// while number <= 10 repeat the block
// at end increment number by 1 and repeat -> number++
for (int number = 1; number <= 10; number++)
{
println(number);
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
println(“Then I let it go again (etc)”);
}
What does this version do?
For loops can be NESTED
for (int number = 1; number <= 10; number++)
{
println(number);
if (number == 5)
println(“Once I caught a fish alive”);
else
if (number == 10)
{
println(“Then I let it go again (etc)”);
for (int countDown = 10; countDown >= 0; countDown--)
println(countDown);
println(“SPLASH!”);
}
}
1
2
3
4
5
Once I caught a fish alive
6
7
8
9
10
Then I let if go again (etc)
10
9
8
7
6
5
4
3
2
1
0
SPLASH!
Simulation (using humans) exercise
• Need roles for
– For (control)
– Initialisation
– Condition
– End action
– Println number
– If/else
– Number == 5
– Println Once I ...
– Number == 10
– println Then I ...
Roles highlighted in different colours
for (int number = 1; number <= 10; number++) // roles 1, 2, 3, 4
{
println(number); // role 5
if (number == 5) // role 6 7
println(“Once I caught a fish alive”); // role 8
else // role 5
if (number == 10) // role 5 9
println(“Then I let it go again (etc)”); // role 10
}
• Line up in order
• For is the controller (keeps track of what to do next) order is 1, 2, 3, (not 4), 5-10, then
4, and back to 3 (not 20, 5-10, etc.
• Println writes on whiteboard
• Variable declaration, assignment, conditions (<= and ==), and maths (e.g. ++) change or
check variable value on whiteboard
Exercises
• Textbook
– Page 42ff
– Example 4.6 to 4.13
– Then go back to fruit bowl problem
– Save your fruit bowl problem to work on later
– Next time Robot 2 Page 49

More Related Content

More from Paul Brebner

Scaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/HardScaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/Hard
Paul Brebner
 
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/HardOPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
Paul Brebner
 
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Paul Brebner
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Paul Brebner
 
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
Paul Brebner
 
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
Paul Brebner
 

More from Paul Brebner (20)

The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
The Impact of Hardware and Software Version Changes on Apache Kafka Performan...The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
The Impact of Hardware and Software Version Changes on Apache Kafka Performan...
 
Apache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Apache ZooKeeper and Apache Curator: Meet the Dining PhilosophersApache ZooKeeper and Apache Curator: Meet the Dining Philosophers
Apache ZooKeeper and Apache Curator: Meet the Dining Philosophers
 
Spinning your Drones with Cadence Workflows and Apache Kafka
Spinning your Drones with Cadence Workflows and Apache KafkaSpinning your Drones with Cadence Workflows and Apache Kafka
Spinning your Drones with Cadence Workflows and Apache Kafka
 
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
Change Data Capture (CDC) With Kafka Connect® and the Debezium PostgreSQL Sou...
 
Scaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/HardScaling Open Source Big Data Cloud Applications is Easy/Hard
Scaling Open Source Big Data Cloud Applications is Easy/Hard
 
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/HardOPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
OPEN Talk: Scaling Open Source Big Data Cloud Applications is Easy/Hard
 
A Visual Introduction to Apache Kafka
A Visual Introduction to Apache KafkaA Visual Introduction to Apache Kafka
A Visual Introduction to Apache Kafka
 
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
Massively Scalable Real-time Geospatial Anomaly Detection with Apache Kafka a...
 
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
Building a real-time data processing pipeline using Apache Kafka, Kafka Conne...
 
Grid Middleware – Principles, Practice and Potential
Grid Middleware – Principles, Practice and PotentialGrid Middleware – Principles, Practice and Potential
Grid Middleware – Principles, Practice and Potential
 
Grid middleware is easy to install, configure, secure, debug and manage acros...
Grid middleware is easy to install, configure, secure, debug and manage acros...Grid middleware is easy to install, configure, secure, debug and manage acros...
Grid middleware is easy to install, configure, secure, debug and manage acros...
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
 
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
Melbourne Big Data Meetup Talk: Scaling a Real-Time Anomaly Detection Applica...
 
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
Massively Scalable Real-time Geospatial Data Processing with Apache Kafka and...
 
0b101000 years of computing: a personal timeline - decade "0", the 1980's
0b101000 years of computing: a personal timeline - decade "0", the 1980's0b101000 years of computing: a personal timeline - decade "0", the 1980's
0b101000 years of computing: a personal timeline - decade "0", the 1980's
 
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
 
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...ApacheCon2019 Talk: Kafka, Cassandra and Kubernetesat Scale – Real-time Ano...
ApacheCon2019 Talk: Kafka, Cassandra and Kubernetes at Scale – Real-time Ano...
 
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
ApacheCon2019 Talk: Improving the Observability of Cassandra, Kafka and Kuber...
 
How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...How to Improve the Observability of Apache Cassandra and Kafka applications...
How to Improve the Observability of Apache Cassandra and Kafka applications...
 

Recently uploaded

Recently uploaded (20)

GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 

Introduction to programming - class 4

  • 2. Housekeeping • The Programming course shared directory is located at XXX. I’ll update this with information, sub directories are: – Exercises – Lessons – Textbook – Students • The processing environment has a shortcut on desktops, so you won’t need to reinstall it again.
  • 3. Repetition (of repetition!) • What does this program do? println(“1”); println(“2”); println(“3”); println(“4”); println(“5”); println(“Once I caught a fish alive”); println(“6”); println(“7”); println(“8”); println(“9”); println(“10”); println(“Then I let it go again (etc)”);
  • 4. Repetition (of repetition!) • This 1 2 3 4 5 Once I caught a fish alive 6 7 8 9 10 Then I let it go again (etc)
  • 5. Using a while loop with 2 bugs int number = 1; // start from 1 while (number <= 10) // while number <= 10 repeat the block { // a block – do everything between { and } println(number); // print the number each time println(“Once I caught a fish alive”); println(“Then I let it go again (etc)”); }
  • 6. Repetition (of repetition!) 1 Once I caught a fish alive Then I let it go again (etc) 1 Once I caught a fish alive Then I let it go again (etc) 1 Once I caught a fish alive Then I let it go again (etc) 1 Once I caught a fish alive Then I let it go again (etc) 1 Once I caught a fish alive Then I let it go again (etc) ...
  • 7. Using a while loop int number = 1; // start from 1 while (number <= 10) // while number <= 10 repeat the block { // a block – do everything between { and } println(number); // print the number each time println(“Once I caught a fish alive”); println(“Then I let it go again (etc)”); number = number + 1; // must increment number by 1 each time }
  • 8. Better - slightly 1 Once I caught a fish alive Then I let it go again (etc) 2 Once I caught a fish alive Then I let it go again (etc) 3 Once I caught a fish alive Then I let it go again (etc) 4 Once I caught a fish alive Then I let it go again (etc) 5 Once I caught a fish alive Then I let it go again (etc) ... 10 Once I caught a fish alive Then I let it go again (etc)
  • 9. Using a while loop and an if int number = 1; // start from 1 while (number <= 10) // while number <= 10 repeat the block { // a block – do everything between { and } println(number); // print the number each time if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) println(“Then I let it go again (etc)”); number = number + 1; // must increment number by 1 each time }
  • 10. Correct 1 2 3 4 5 Once I caught a fish alive 6 7 8 9 10 Then I let it go again (etc)
  • 11. for loop this while loop is identical to for loop int number = 1; // start from 1 while (number <= 10) // while number <= 10 repeat the block { // a block – do everything between { and } println(number); // print the number each time if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) println(“Then I let it go again (etc)”); number = number + 1; // must increment number by 1 each time }
  • 12. for loop // start from 1 // while number <= 10 repeat the block // at end increment number by 1 and repeat for (int number = 1; number <= 10; number = number + 1) { println(number); if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) println(“Then I let it go again (etc)”); }
  • 13. comparison // while loop int number = 1; // start from 1 while (number <= 10) // while number <= 10 repeat the block { // a block – do everything between { and } println(number); // print the number each time if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) println(“Then I let it go again (etc)”); number = number + 1; // must increment number by 1 each time } // for loop for (int number = 1; number <= 10; number = number + 1) { println(number); if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) println(“Then I let it go again (etc)”); }
  • 14. number++ // start from 1 // while number <= 10 repeat the block // at end increment number by 1 and repeat -> number++ for (int number = 1; number <= 10; number++) { println(number); if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) println(“Then I let it go again (etc)”); }
  • 15. What does this version do? For loops can be NESTED for (int number = 1; number <= 10; number++) { println(number); if (number == 5) println(“Once I caught a fish alive”); else if (number == 10) { println(“Then I let it go again (etc)”); for (int countDown = 10; countDown >= 0; countDown--) println(countDown); println(“SPLASH!”); } }
  • 16. 1 2 3 4 5 Once I caught a fish alive 6 7 8 9 10 Then I let if go again (etc) 10 9 8 7 6 5 4 3 2 1 0 SPLASH!
  • 17. Simulation (using humans) exercise • Need roles for – For (control) – Initialisation – Condition – End action – Println number – If/else – Number == 5 – Println Once I ... – Number == 10 – println Then I ...
  • 18. Roles highlighted in different colours for (int number = 1; number <= 10; number++) // roles 1, 2, 3, 4 { println(number); // role 5 if (number == 5) // role 6 7 println(“Once I caught a fish alive”); // role 8 else // role 5 if (number == 10) // role 5 9 println(“Then I let it go again (etc)”); // role 10 } • Line up in order • For is the controller (keeps track of what to do next) order is 1, 2, 3, (not 4), 5-10, then 4, and back to 3 (not 20, 5-10, etc. • Println writes on whiteboard • Variable declaration, assignment, conditions (<= and ==), and maths (e.g. ++) change or check variable value on whiteboard
  • 19. Exercises • Textbook – Page 42ff – Example 4.6 to 4.13 – Then go back to fruit bowl problem – Save your fruit bowl problem to work on later – Next time Robot 2 Page 49