Coding a Card Game: Using Loops
A card game we played together recently inspired a new project we are working on during Computer Science/Coding. After breaking down the game and getting to the core of the rules and how the game flowed, we moved to writing pseudocode together. Then, a demonstration lead by Mrs. Lai involving articulating the steps of making a peanut butter and jelly sandwich helped us refine our understanding of the importance of not assuming anything while writing a program. We learned that writing our code out in a very clear and incremental fashion is necessary . . . when we didn’t have the steps of making a peanut butter and jelly sandwich articulated clearly enough, we almost put the peanut butter on the packaged loaf of bread! We refined our pseudocode with this new understanding and prepared to begin to code our game.
As we began our coding project, it was obvious we were going to leverage our understanding of strings, variables, and raw input, but we also ran into a problem: Since the game player repeatedly draws a card, we needed to expand our coding skills to include loops. After a discussion on loops and a short exercise practicing this skill by imagining ourselves helping NASA create a countdown for a rocket blastoff, we began to build the code for the card game using a "while loop." After the Thanksgiving break, we’ll move to writing the full code for the card game using the practice of paired programming, in which two programmers work together on one workstation. During this technique, one programmer “drives” while the other, the observer, reviews each line of code as it is typed in. The goal is to have a working program before the winter break.