Assigned: Wed, Mar 17
Due: Mon, Mar 29 Tue, Mar 30, 11:59pm
cs101
course folder.assign1
folder and confirm you see the happy-cat.rkt
file there.This assignment begins where assignment 1 left off. As I demonstrated in class, for assignment 2 you will combine your two separate big-bang programs for the cat and the happiness gauge into one big-bang program. This new program will display the cat moving across the screen, and below the cat, the happiness gauge will be decreasing with each tick of the clock, unless the user presses the up/down arrow keys to feed/pet the cat.
happy-cat.rkt
Now you will combine the first two big-bang
programs you wrote for assignment 1 into a single big-bang
program.
The first program you wrote had a cat move from left to right across the empty scene, wrapping around when it reached the right edge, continuing forever. The state of this world was a number, representing the cat's x-coordinate in the empty scene.
The second program you wrote created a happiness gauge that diminished with each tick of the clock—unless you made the cat happier by petting it or feeding it (with the “down” or “up” arrows on the keyboard). The state of this world was also a number, but this time it represented the value of the happiness gauge, which ranged in value from 0 to 100.
Now you get to put these two programs together into a single program, but to do so, you will need a structure to represent the state of the world, because you have two values you need to keep track of simultaneously: the cat's x-coordinate, and the value of the happiness gauge (both are numbers).
Here's the link to the exercises in the text: Section 5.11 More Virtual Pets
You will complete Exercises 88–91.
Advice:
happy-cat.rkt
, and call it happy-cat-90.rkt
. This accomplishes two things:happy-cat-90.rkt
and start again. In case you're curious, I had over 25 tests in my solution. You should have at least that many in your solution.
happy-cat.rkt
file onto your browser where it says, “Drag files here to add them to your repository”happy-cat.rkt
file file should now be in your Assignment 2 GitHub repository.