Assignment 2 - Spring 2021

Virtual Cat World

Assigned: Wed, Mar 17
Due: Mon, Mar 29 Tue, Mar 30, 11:59pm


Assignment Setup

  1. Open a browser and copy/paste this URL: https://classroom.github.com/a/C1szqbGi

  2. Login to Github and you will be prompted to accept this assignment
    1. After you click on the [Accept this assignment] button, you will see a new page display in your browser with the message:
      1. You accepted the assignment, Assignment 2. We're configuring your repository now. This may take a few minutes to complete. Refresh this page to see updates.
    2. After you refresh the page you should see a page with the message: “You're ready to go!”
    3. Note: this will create your own copy of Assignment 2 for you to work on, but it's not on your computer yet.

  3. Click on the URL where your assignment repository has been created: https://github.com/Vassar-cs101-mlsmith/assignment-2-yourGitHubID
    1. you are now on the GitHub page for your Assignment 2 repository

  4. Click on the green button to download your [Code]
    1. a “Clone” dialog box will appear, with the HTTPS tab underlined in red (if not, click on the HTTPS tab to select it)
    2. select the last option labeled “Download ZIP” and save it on your computer
    3. move the Assignment 2 zip file from its download location to your cs101 course folder.
    4. extract the contents of the zip file either by double-clicking on it or control-clicking on it and selecting the appropriate option to extract its contents
    5. navigate into your assign1 folder and confirm you see the happy-cat.rkt file there.

Description

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:

In case you're curious, I had over 25 tests in my solution. You should have at least that many in your solution.


Submitting your work