CS139 Algorithm Development
|
|
Software Requirements Specification
Programming Assignment 6
WordGuess Version 2
Due No Later Than Friday, Dec 10 at 7PM
Introduction
Purpose: This application will be a variant of the
WordGuess game that you did as PA4. In this
version, you will be making the WordGuess game for multiple players.
Changes will need to be made WordGuess.java.
This document will describe the changes that you need to make to the
original game. Refer to the PA4 document for the original items.
Objectives - At the conclusion of
this exercise the student will demonstrate that they can:
- Create a class from which we will make objects.
- Instantiate an array of such objects.
- Use that array in an application.
- In this particular application, you will be implementing a
multiplayer version of the WordGuess game.
- Do everything necessary to implement, compile, execute and debug
a Java program.
- Conform to the style guide for this class.
Deadlines
- Successfully submit to the submission system no later than 7pm on
Friday Dec 10.
- Bring the hardcopy to your final exam.
- There is no late penalty. No late submissions will be accepted.
Prerequisites
You should be familiar with the material about
classes from Gaddis, chapters 6 and 9, and the material related to
arrays and specifically arrays of objects from Gaddis, chapter 8.
Starter files
You will use as a starter, your completed PA4. If you did not
finish that PA, you may use this
version as your starter. Dictionary.java and WordGuessDriver.java may be obtained from the
original PA (linked above).
You also have a sample JGrasp dialog here.
New file
You will need a new file, Player.java.
This class will contain the attributes and methods of players of the
game. It must meet the specification as described by the following UML
diagram.

Detail about each method
- Constructor - Takes in a String representing the player name and
sets the value in the name field. The constructor should also
initialize the score to 0.
- getName - Accessor method to return the name of the Player.
- getScore - Accessor method to return the current score for the
Player.
- addPoint - Mutator method to increment the score by one. (The
Player gets a point for every word they successfully complete.)
- toString - Accessor method to return a String in the form of ("Player: %20s\t%d", name, score)
Changes to WordGuess.java
- You will need a new private field players,
which will be an array of Player
objects. You should initialize this array to null in your constructor,
because you will build the array in the playGame
method.
- You will still produce the welcome message.
- You should then call a new private method, buildPlayers
which takes no parameters and returns nothing. It will do the following:
- You will need to prompt for the number of players. (Output a
blank line, then the String, "How many players today? ". Output a blank line after reading the input value.
- If a bad value is entered (either a zero, negative number, or
something other than an int), assume 1 player.
- You will also need to prompt for the names of each player and
instantiate each of the player objects in the players
array. (Output the String, "Enter player %d's name: ",
where the substitution is the number of that player (beginning with
1). Output a blank line after reading in the value. Repeat this
step for each of the players.
- You will need to change the game play as follows:
- Change the prompt: "What is your guess: "
to "%s, what is your guess? " where the
substitution is the player's name.
- If the player successfully guesses a letter, change the success
display from "YES!! %s is in the word."
to "YES!! %s is in the word. Go again.".
- Play will continue with the same player until the player either
finishes the word or until they miss a letter.
- If the player is unsuccessful in guessing a letter, change the
display from "Nope... %s is not in the word."
to "Nope... %s is not in the word. %s's turn.",
where the second substitution is the next player's name.
- The game will continue until a player finally guesses the whole
word. Play will not stop when there are 6 bad guesses.
- At the end of each round, the winning player is awarded a
point. (use the addPoint method in Player).
- Change the display, "\n\tYou WIN!!!!\n" to "\n\t%s WINS!!!!\n" where %s is the name of the winning player.
- Change the line, "Strikes: %d\tBad Guesses: " to "Bad Guesses: "
- At the beginning of each subsequent game, the player just after
the winning player will begin the game.
- When play ends, before displaying the message, "Game over. Play again soon." display each player's
name and score on a separate line and output a blank line. (Use your
toString method in Player.)
Strategies
- Make sure you understand how the flow of the game will proceed.
Instead of looping through one player you will loop through one player
while successful, then loop through each of the players before deciding
whether or not to continue and play another game.
- Think carefully how you will end if a player who is not the last
player successfully completes the word. The next player to take a turn
will be the next player in line.
- Think carefully about how you will go from the last player in the
array to the first as you go through each round.
Grading and handing in your work
- You will earn 80 points for successfully submitting this program.
- The remaining 20 points are earned by strict adherence to the
Style Guide for this class.
- You must successfully submit by Friday Dec 10 at 7pm.
- You must turn in the hardcopy no later than your final exam time
duing the Dec 13 week.