CSci 1301: Takehome 1

Due: Wednesday, October 12 at 11:59pm by e-mail (no late work accepted)

Total: 30 points

This is individual work. You are not allowed to spend more than 6 hours on this test. This includes any reading that you do to help you solve the problems.

Make sure to write your name in the file(s) you submit. You may submit one or two files.

Use helper functions as needed. All your functions (including all those you use in big-bang) must have documentation with the types of parameters and results, a function description, and, whenever possible, check-expect tests.
When defining your own structures, clearly explain what all the fields mean.
Comments, helpful variable names, and good code style and formatting are a very important part of your grade. You don't have to look for the shortest solution, but you should eliminate unnecessary code repetition if possible (use helper functions).

Task 1 (5 points): middle character of a string

Write a function middle that consumes a string and returns its middle character. If the string has even number of characters, the one closer to the front is returned. The following are tests for the function. Please make sure to write the signature and the (more precise) description.


(check-expect (middle "") "")
(check-expect (middle "a") "a")
(check-expect (middle "cat") "a")
(check-expect (middle "orange") "a")
(check-expect (middle "kiwi") "i")
  

Task 2 (25 points): a world problem

Your goal is to implement a simple "game" with two players: Alex and Pat. Alex and Pat both start with the score 0. The first player to get the score of 20 or above wins.
The players names and scores are dispalyed in the upper half of the screen: Alex to the left, Pat to the right.
Players scores can be increased in the following way:

The bottom half of the screen has a picture of a die in the middle and two arrows on the two sides pointing left for Alex, right for Pat. Start with showing just a number on the die, not the dots (you can change it once you have everything else implemented). The initial number is 1. This is how dice rolling works: Additionally: Extra credit, up to 4 points:

Implement the die as a picture with the corresponding number of dots: https://en.wikipedia.org/wiki/Dice.

You need to clearly describe what your world state is. You also need to provide signatures an ddescriptions for all your functions (those used in the big-bang and helper functions). Choose informative names for your functions and constants.

If something is not working, please comment it out and write comments about why you think it's not working and how you would be going about fixing it if you had more time. Make sure that the code you submit runs, even if it doesn't implement all of the functionality.

Your work will be graded based on:

Happy programming!

What to submit

Submit all your files as attachements in an email to me. Please include your name and a task number at the beginning of each file, in a comment. In your email message please include any comments about what works and what doesn't, as well as thoughts on how you would've continued if you had more time (if you run out of time). Also please include the total time you spent on the test.


CSci 1301 course web site.