Part 1 mini-project: A flowchart for a real program
The first mini-project has no code. It is a flowchart, drawn on paper, for a real program — proof that you can plan a whole program before writing it, using the three patterns from Chapter 03.
What to build
Pick one of the following:
- A small game (Rock-Paper-Scissors, Hangman, a memory game).
- A daily routine (your morning, your bedtime, getting ready for school).
- A chore with a clear stopping point (washing the dishes, walking every dog in the house, watering every plant on a shelf).
Draw a flowchart for it on one sheet of paper. It must contain all three patterns from Chapter 03:
- Sequence: at least two actions in a row.
- Decision: at least one diamond with a yes-branch and a no-branch.
- Repetition: at least one arrow that points back to an earlier step.
That is the whole spec. There is no starter file — just paper, a pencil, and an eraser.
Worked example: Number Guessing Game
The Number Guessing Game from Part 4 (the mini-project you will code at the end of that part) has all three patterns. Its flowchart looks like this:
Find the three patterns:
- Sequence: pick a random number → set attempts to 0 comes before the loop, and ask for a guess → add 1 to attempts sits at the top of the loop body.
- Decision: is the guess too low? and is the guess too high? are two decisions. Either branch loops back; the third path (neither low nor high) reaches Done.
- Repetition: the long arrow on the left, going back from Say "too low" and Say "too high" up to Ask the player for a guess, is a loop. The correct! case is the exit.
When you read that project's code, you will recognise this shape:
for {
guess := readGuess()
attempts++
if guess < target {
fmt.Println("Too low.")
} else if guess > target {
fmt.Println("Too high.")
} else {
fmt.Println("Correct! You got it in", attempts, "attempts.")
break
}
}readGuess() is not part of Go. It stands in for the few
lines that read a number from the keyboard, which Chapter 15 teaches. A
for with nothing after it repeats forever, and
break leaves the loop; together they are the loop arrow.
The if/else if/else is the two decisions. The two lines
above it are the sequence in the loop body. The flowchart became code,
almost step for step.
How to check your own flowchart
When you finish, read it aloud while tracing your finger along every arrow. It should sound like an instruction sheet for a careful but clueless friend. If it sounds natural, the flowchart is probably good. If it skips a step, your finger snags right there.
Also check:
- Does every arrow eventually reach an end (a
( Done )or( End )box)? - Does every diamond have two arrows leaving it (one yes, one no)?
- Does the loop's question include something that changes inside the loop body? If the question never gets a new answer, the loop never ends.
Done?
When your flowchart passes the read it out loud test and has all three patterns, you are done. Show it to someone if you want — explaining your own flowchart is a great test of whether you understood it.
The next chapter — Chapter 06 — Setup — installs Go and a code editor on your Windows machine. After that, you start turning flowcharts into real code.