*
Computer Programming I
Programming Assignment 9 - Game.java *

Problem

Write a program to play a simple card game.

Specification

Each player takes the same number of cards from 1 to 9.
Inputs less than 0 or greater than 9 should be trapped.
Cards are valued from 1 to 9.

The player with the highest card total is the winner.
Equal totals are declared a draw.
Only one of the three messages actually prints ( A wins. B wins. Draw. ).

Discussion

Use a random number generator to generate card values. This will be discussed in class.

The program should loop until the user enters a 0 to exit the game.

Create program documentation as game.doc or game.txt. You may use this sheet as partial documentation but should still write an algorithm and constants/variables for each function. Include a module structure chart as well. The main function will be designed and written during class.

Use the standard program header as shown in Program 2 (Use the one given to you).

Comment your program for readability and ease of maintenance. Include purpose, preconditions, postconditions and data flow documentation for each function.

Test your program thoroughly.

Sample Run

Cards (1-9, 0 exits) : -1
Cards (1-9, 0 exits) : 10
Cards (1-9, 0 exits) : 9

A ------> 9 9 9 9 9 9 9 9 9 = 90
B ------> 9 9 9 9 9 9 9 9 9 = 90

Draw.  -or-  A wins.  -or-  B wins.

Cards (1-9, 0 exits) : 0

Goodbye!


Submission

Place your source file and documentation file in your H:\CP1\Java\BookClasses\ folder by the due date.

*

This page maintained by bobh@hesston.edu