Assignment 10
Due Date Monday 02/25 at 9pm
Purpose To practice list processing and iterative refinement.
You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions. Failure to submit a .rkt file will result in a 0.
You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.
Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment.
You must follow all the steps of the design recipe when completing this assignment.
Please be sure to look at the feedback for assignment 9 before submitting, as we will be grading you more harshly on things we have warned you about before.
You must submit this assignment with your NEW partner. Please make sure you can submit with your partner before 5pm on Monday or we cannot guarantee that you will be able to submit your homework before the deadline. If the course staff are unable to assist you after 5pm and this causes your homework to be late we will not grant an extension.
You should not use list for this assignment (but you may use cons).
Sleeping Soundly - Part 2
Recall that in assignment 6 we helped Al Herpin with his sleeping troubles. Well, unfortunately that doesn’t seem to have worked. Al has decided that the reason for this is the lack of numbers involved. As such, he took a basic math class and asked you to develop a new program.
In this program, sheep will carry mathematical expressions across the screen and the player will have to type the answer to these expressions to clear the sheep off the screen. Unlike in the previous program, there can be any number of sheep, not just one. If a sheep reaches the right edge of the screen the player loses and the program should display a screen that has some sweet, consoling message about that. The program will be given the number of sheep that should cross the screen and if the player answers all the sheep equations given, they win and the program will display a congratulatory message so they can brag to all their friends.
Exercise 1 To start, design the data for your world program. It will be VERY useful to recall data you designed in previous assignments. A tutor or TA will be happy to hlep you walk through any feedback from these assignments. Designing a world program with an incorrect data definition will lead you down a dark and dangerous path filled with nightmare horrors. A few things to note:
Your game will need to be able to handle any number of mathematical expressions.
Each mathematical expression should have two integers and an operation: addition, subtraction, or multiplication. This type of expression should be unbelievably familiar to you.
Each sheep should hold a mathematical expression and should move across the screen from left to right. The y-coordinate of the sheep should not change.
Unlike in the previous sheep game you should be able to see more than one sheep at a time as they move across the screen. Note that this means your world state will have to keep track of more information.
Exercise 2 Design your program. A few things to note:
The main program should take in a positive integer, representing the number of equations you have to solve to win the game and another positive integer, representing the distance between the sheep. It should not take in any other inputs.
The sheep should be holding randomly generated mathematical expressions so that the game is different each time you play.
The sheep should move at a constant rate across the screen but this rate is up to you. The faster they go, the harder the game will be.
You will have to determine when to generate a new sheep based on the distance you input to the main program. There are several ways to determine when a new sheep should appear. As with all ambiguities, make a decision and provide documentation so your grader knows what you chose to do.
When a player enters a number, you should clear any sheep that are on screen for whom that number is the solution to their mathematical expression. This may mean that more than one sheep is cleared at a time (if the player gets lucky).
When a player enters a number, the text box they are typing in should clear automatically. They should not have to manually delete their last answer.
The game should display a text box to show what the user is typing, in addition to showing the sheep moving across the screen with the equations on them.
The player should not be able to type anything other than integers. They should be able to type positive or negative integers but should not be able to type something like "3-4" or "3.14" or "hi". It would be VERY helpful to consider your work in previous assignments. A tutor or TA will be happy to help you walk through any feedback you received on these assignments.
If the player successfully solves all the mathematical expressions, you should display a screen that indicates that they won the game. If a sheep reaches the edge of the screen before they solve that sheep’s mathematical expression, you should display a screen that indicates that they lost the game.
To help players who are not so good at typing under pressure, you should include backspace functionality. That is, pressing the backspace key should delete the last character the player typed. If they have not yet typed anything it should not do anything but it should still not break your program.