CSC171 Introduction to Computer Programming
Fall 2018
Homework 5


Solve the following problem, using stepwise refinement as we discussed in class. Start with a high-level algorithm, in the form of a flowchart. Each step represents a subtask. Draw a flowchart for each subtask. Note: subtasks can be further divided into sub-subtasks. Continue stepwise refinement until it is clear how to translate each step into Java. Do not implement it yet. For this homework, you will just hand in flowcharts, and indicate methods to be defined (based on your subtasks). For each method, what does it do, what information does it need and what does it return. (If it does not need any information, or does not return anything, indicate that.)

The problem:

Design an application that plays a text-based game between user and computer, continues playing games until the user decides to stop, keeps track of stats (user wins, losses and ties), and prints those stats when games are completed. You may start with your solution to lab exercise 22b, in which you designed a Blueprint class of your choice. Each player (user and computer) chooses values for the attributes of the Blueprint. The computer chooses its values randomly. Design rules by which 2 objects of your Blueprint can be compared in order to determine a winner. For example, you may compare 2 BaseballPlayer objects based on some computation involving multiple attributes; you may compare 2 Player objects (each of which encapsulates a choice of ROCK, PAPER or SCISSORS) by the rules of the Rock-Paper-Scissors game (ROCK beats SCISSORS, SCISSORS beats PAPER, PAPER beats ROCK). Alternative possibilities include, but are not limited to, modifying this game, having each Hand object encapsulate a Card or Cards (as in a deck of playing cards, e.g. Queen of Clubs, etc), or having 2 characters with attributes such as health, strength, agility etc (and rules that you define for determining a winner between the two).

The application should reveal both choices (user's and computer's) and indicate if the user won, the computer won, or if it was a tie. Continue playing until the user decides to stop, then print the number of wins, losses and ties.

In addition to the specifications above, your algorithm (to be implemented in the next assignment) should:

Finch option: Let the Finch be the computer player, and communicate using motion and/or colors, e.g. RED may indicate one choice, BLUE a second choice, and GREEN a third choice; motion/sound may indicate the result.

The assignment may be done individually or in pairs (group of 2, following the principles of pair programming as discussed in class). If you work with someone else, hand in ONE copy with both names on it.

[Back to the Assignments Index]