Programming Assignment

Cootie Player


OVERVIEW

The children's game of Cootie is played with pencil, paper, and a six sided die. Two players compete to be the first to draw a complete "cootie" which must have a body, a head, two eyes, two antennae, six legs, and a tail:

 
  ! !

 (o o)

- [ ] -

- [ ] -

- [ ] -

   T
 

Each person in turn rolls the die, and depending on the roll, gets to add a body part to their drawing. 1 means the body may be drawn (brackets), 2 means the head may be drawn (parentheses), 3 means a leg may be drawn (dash), 4 means an antenna may be drawn (exclamation point), 5 means an eye may be drawn (letter o), and 6 means the tail may be drawn (letter T). The body must be drawn first; the head must be drawn before eyes or antennae. Whichever player completes their drawing first is the winner.

We want a computer Cootie player that can draw its own cootie according to the rules of the game. The human player must roll the die and enter the value to the computer. The computer then determines which part to add (if any) and displays the drawing. The human has to draw his or her own cootie. The computer should be able to detect when it has completed its drawing and display an appropriate message.
 

1.0 INPUT REQUIREMENTS

1.1 Roll: an integer between 1 and 6, the value of the die roll for the computer's turn.

  2.0 OUTPUT REQUIREMENTS

2.1 Prompt for input of roll.
2.2 The Cootie drawing (or partial) using ASCII characters.
2.3 "Can't add a part" message if rules don't allow a move.
2.4 Done message when the drawing is complete.
 
 

3.0 FUNCTIONAL REQUIREMENTS

3.1 Start with an empty drawing.
3.2 Display prompt for input of roll.
3.3 Determine if a part can be added to the cootie, depending on the roll:

3.3.1     1 = body
3.3.2     2 = head
3.3.3     3 = one leg
3.3.4     4 = one antenna
3.3.5     5 = one eye
3.3.6     6 = tail
3.3.7     The body must be drawn before any other part (I.e., until a 1 is rolled, no part may be drawn).
3.3.8     The head must be drawn before eyes or antennae.
3.4 If no part can be added (according to the rules), display a message.
3.5 If a part has been added, display the updated cootie drawing.
3.6 Count how many turns are taken.
3.7 Determine if the drawing is complete, i.e., all the parts have been drawn.
3.8 When the drawing is complete, display a message that tells how many turns were taken to finish the cootie, then terminate.   4.0 ERROR HANDLING
4.1 If the input for the roll is less than 1 or greater than 6, display an error message and allow the user to re-enter the value.

5.0 USER INTERFACE

5.1 The interface will be a simple scrolling text display using ASCII characters for the drawing, as shown above.
5.2 Input prompt: "Input dice roll: "

5.3 Can't add part message: " Can't add a part."
5.4 Done message:
"Congratulations you have completed your cootie!
 It took you __ turns to finish your cootie."



Extra Credit Project

Objectives

Resources

Ground Rules

2.0 Constraints


The game logic is to be implemented in the main function of a separate driver file named magpiefate.c


3.0 Testing

You don't need to create unit tests for this program.  Simply test your program manually by trying all the game conditions as described in the rules.

4.0 Grading

This assignment is worth 50% of a regular project.

Since this is an extra credit assignment, only submissions that meet all the requirements will receive credit.  Your program will be run with the instructor's automated test suite and programs that don't pass all the tests are unlikely to receive any credit.

Remember, your program will be tested on Unix1.  Code that does not compile will receive a grade of zero.

5.0 Submitting Your Work

You need to submit your source code electronically using the   handin   utility: No late submittals will be accepted! 

  1. You will submit a single source code file, named as follows:
       cooties.c    contains the game main program and any helper functions you create (optional).
    Do not submit any other files.
  2. Move the necessary file(s) to your Unix1 account using your favorite secure file transfer program.
  3. Log on to Unix1 using your favorite Secure Shell client program.
  4. Change directory (cd) to the directory containing your source file to hand in.  
  5. Be sure to compile and test your code on Unix1 using the required compiler flags ( -Wall -ansi -pedantic) one last time just before turning the files in.
  6. Submit your code using handin:
    handin graderjd Project3  cooties.c