Video Introduction (4 minutes) <<--- Watch this video first, then
English IDE <<--- Click this link and rewrite (improve) your first program here.
When it runs correctly (without errors or warnings) click
the yellow Done button.
Then come back here and click this Next link to skip down to the next video.
If it's not a link yet, you might need to refresh your browser, or else click this button to call a mentor:
If you are like me and prefer to read at your own pace instead of whatever pace set in some video, You can read the transcript (and probably come out ahead of the non-readers).
"put it together"
Get piece of bread.
Get piece of bread.
get jam on knife
Spread jam on bread.
get pb on knife
Spread PB on bread.
Put bread pieces together.
put it together
It's a start. But the real world is not a straight line like this program. We have turns and switches, conditions and curlicues.
Things Happen, and we need to deal with it. Maybe you ran out of grape jelly, so you must make your sandwich from strawberry. Or maybe grape is boring, let's try peach today. You can do that: "I feel like strawberry today," and you alone know how you feel.
So let's pretend we are making this sandwich for your finicky brother or cousin or whatever, and he's on a rigid schedule: Monday it's grape, Tuesday it's peach, Wednesday it's strawberry.
On the third line of my program, where it says
get jamChange that one line to these two lines:
if it is Monday get grapeDo you see the calendar near the left edge of the Kitchen computer? What day is it when you run this revised program? Did it choose the right jam?
any other day get strawberry
How would you know if the other line worked correctly? I guess you could wait until that day of the week rolled around, then run it again, but there's an easier cheat: Insert at the beginning of the main program, before the line where it calls the subroutine "get stuff" but inside the "make PBJ" subroutine
it is Tuesday(or whatever day it isn't), then try it again. Did you see the day change on the calendar? You can also change the month, like
it is Decemberor the time on the wall clock over the fridge:
it is 11:30But testing the exact time is difficult, it might be better to try for before or after a particular time.
Anyway, your finicky cousin didn't get his peach jam on Tuesday. You can fix that. Then click the Done button. If you get stuck, that's what the Mentors are for (click this button to get help)
Congratulations! Your program ran correctly. Click this
link to advance to the next segment: Iteration
There's some butter in the fridge too, but I ran out of time before I could tell the computer how to get butter on the knife so it can spread it on your bread. Yes, everything the computer knows how to do, somebody (in this case, me) told it how to do that. All that animation, it's (Java) code in the Game Engine, which you will learn how to do yourself later in this course. The mayo was for when I add deli meats for a ham&swiss sandwich, but like I said, I ran out of time. Programming is like that. Maybe next year (if you come back). But the cereal in a bowl with milk works. You can even eat it. Try it. Start simple and see what is assumed.
[2022 September 28]