The trick would be provide written responses that properly highlight everything. This would let you verify that every button works right for a single board setup. Let me sketch out what I'm thinking. Make sure they're not re-declaring the variable with var inside the function. If we add 20 to each of those the values will be over 255. If they had started a different way, or made different decisions along the way, the actual code may have come out much differently, even if the program worked the same. Show this image of the sketch mock-up of the app.
The board should change each time you click a button 3. You can think about your pause points in this lesson, where you might gather everyone to check for understanding, or at least do a check-in with various groups. I'll be working on a course for Pluralsight on Visual Studio Code coming soon! If we add -3 to the score that's the same as subtracting. This is a great sketch. Choose the Student-Developed Algorithm The program code below is taken from the Color Sleuth activity you just completed. Student Instructions Let's make one square slightly different Add two lines to the bottom of the code you have that look like something like this. You might be interested to see how someone else went about it.
As you follow the story Alexis and Michael will solve problems and make decisions about how to write the code, but you will do all of the actual code writing. In fact, it captures many of the elements of the actual conversations between the authors of Color Sleuth app as they developed it for this lesson. The difference between rgb 250,250,250 and rgb 255,255,255 is practically nothing. Two questions address algorithms and one is a refresher on abstraction. Assume that all of the design layout is done -- what's the first code you'd write to get things started? Just need to finish it.
Most of the time the things you try out, solutions you come up with, don't all work. Why set both text labels each time? For the app we're making we probably don't need transparent colors so this will make our code simpler to read. When you do opt to begin it, students should use the materials in the to prepare. To do that though we need to know which player's score to update. Console messages showing the correct answer for each new board. You're just wrapping up all the code you wrote inside a function called setBoard Common Mistake: forgetting to call setBoard at the top of the program after putting all the code inside a function.
The goal is to follow a creative process from beginning to end to see how ideas come to life, as well as to use your new knowledge of if statements. Then every time a button is clicked, we make a new game board, and we can also switch the player from 1 to 2, or 2 to 1. Just grab the code folder and go. For example, there's a chance that the 3 random numbers we make will come out to be something like 250, 250, 250. But that would start to become big and unwieldy.
See the example below to give them guidance. It's worth verifying that students have successfully completed these before moving on. But now checkCorrect needs a way to know both which button was hit so we can compare it to randButtonId. Many times you start down one path and realize you might want to start over. So, while this would be unexpected from students on a first pass -- you could add another condition to all of these to make sure that it's player 2's turn before declaring anyone the winner. Following an imaginary conversation between two characters - Alexis and Michael - students follow the problem solving and program design decisions they make for each step of constructing the app. .
Try to solve all the levels in this stage. Would you be interested to see the code of someone else who tried to write the same end game condition as you? We can just store a number: 1 for player 1 and 2 for player 2. Here is the suggested solution. Second: Add 20 to each of the R, G, B values to make diffColor This means you will have to insert several lines of code in two different places in your program: just before you create var color and just before var diffColor. And this function's whole job is to figure out whose turn it is and add the amount given in the parameter to the correct player's score.