Write a line once, use it everywhere. Here's the trick that keeps your code short and your changes easy.
Not started yet.
Students will add a MinusButton and a ResetButton, write click methods for them, and then write a method of their own called UpdateLabel that shows the count, calling it from all three click methods.
A method is a named recipe. Writing the steps once and calling the method by name wherever they're needed means a change only has to be made in one place.
Calling a method means using its name followed by parentheses and a semicolon. Without the parentheses, the line does not run the method.
C# is case-sensitive, so UpdateLabel and Updatelabel are two different names. The minus button can still go below zero in this lesson, and the next lesson fixes that.
Calling UpdateLabel without parentheses, so the line never runs the method and the label doesn't change. A red error usually shows.
Spelling the method name differently where it's written and where it's called, such as a lowercase letter that should be capital.
Wondering why the number goes negative. That's expected for now, and the next lesson stops it.
When this lesson is done, the scene should show Main with CountLabel, PlusButton, MinusButton and ResetButton under it, all spelled and capitalized exactly that way.
Pressing F5 should show 0 at the start, the plus button should go up by one, the minus button should go down by one, and the reset button should return the number to 0. The number may go below zero, which is fine for now.
A parent can open Main.cs and compare it to the code in the last Watch It Worked, where the line that sets the label's text appears only once, inside UpdateLabel.
Optional. Watch one first, then press Add to put it in the Visual Panel for a student.
Read-aloud is not available in this browser. Try Chrome or Safari.
Before You Start
The words this lesson uses. Tap a card to see what it means, then come back to them whenever a question uses one.
Part One
Questions about the story you just read. Pick your answer straight off, or press Find it in the story if you would rather hunt for the sentence first.
Part Two
The word cards are at the top of this page. Look back at them as often as you need, then answer.