PA5
Programming Assignment 5
1 Learning Objectives
This assignment is designed to help you learn several things, including:- Creating classes of different kinds; and
- Understanding basic UML diagrams.
It will also help you get better at using objects and testing.
2 Introduction
7 Little Words is a popular game that is available as both a "Web App" and a "Phone App". For this assignment, you are going to create a JMU-themed (i.e., purple and gold) knockoff called 00000111 Little Words that can run on a desktop/laptop computer.When running, it will look something like the following.

3 Game Play
00000111 Little Words is a single-player game. The player's objective is to guess the seven words that correspond to the seven provided clues. There is no time limit and there is no penalty for incorrect guesses.3.1 Information Provided to the Player
The player is provided with seven clues and the length of the corresponding word/answer. In addition, the player is provided with a group of tiles, each of which contains a slice of one of the words to be guessed.3.2 Guessing
To make a guess, the player selects tiles (in order) and then presses the Guess button. When a tile is selected it is temporarily removed from the board.After a correct guess, the tiles that constituted the guess are permanently removed from the board. After an incorrect guess, the tiles that constituted the guess are returned to the board (i.e., made available for another guess).
3.3 Hints
At any point, the player can request (with no penalty) a hint for a particular clue. Specifically, the player can ask for the first letter in the word associated with the clue, the first tile in the word associated with the clue, or the answer.3.4 Shuffling
At any point, the player can shuffle the available tiles (which may help the player see patterns that weren't visible before).4 Game Creation
Games are created by an author, not the player. To create a game, the author creates a single text file that contains seven dash-delimited records/lines. The first field in each record/line contains the answer, and the second contains the clue.Note that the author does not create the tiles, the program creates them from the words using a slicing algorithm.
An outside author created three game files that you can use for testing.
Of course, you can easily create more.
5 System Design
The system that you must implement is summarized in the following UML class diagram.You are responsible for implementing the classes in black. The .class
files for the classes in blue are available from the following links.
The first three are part of the graphical user interface (GUI), the last is a utility class for reading files. Note that you do not need to (and should not) use the Tile
and GuessField
classes directly, they are used by the GameBoard
class. The purpose of the methods in the other classes should be apparent from their names.
6 The Main Class
The main class for this assignment isSevenLittleWords
. It must:
- Construct a
GameInfo
object using the file name passed to it as command-line argument 0. If no such argument is provided, it must print an appropriate error message on the console and terminate. - Construct a
GameBoard
using theGameInfo
object. If theGameInfo
object isn't read properly/completely, it must instead print an appropriate error message on the console and terminate. - Show the
GameBoard
object by calling itssetVisible()
method and passing it the valuetrue
.
7 The Slice Class
ASlice
is a two-letter or three-letter portion of a word.
A Slice
can either be in the used state or the unused state. When a Slice
is in the unused state its toString()
must return its text. However, when it is in the used state it must return the empty String
(i.e., ""
).
It must be possible to put a Slice
in the used state by calling its use()
method. On the other hand, it must be possible to put it into the unused state by calling its reset()
method. Its isUsed()
method must return true
when it is in the used state and false
otherwise.
8 The WordUtilities Class
The only public method in theWordUtilities
class is slice()
. It must create the slices for the word it is passed in a manner that is consistent with the following specifications.
- All the letters in a slice must be uppercase characters.
- When the length of the word (in characters) is evenly divisible by three, each slice must contain exactly three characters.
- When the length of the word (in characters) is instead evenly divisible by two, each slice must contain exactly two characters.
- When the length of the word (in characters) is neither evenly divisible by three nor evenly divisible by two, slice 0 must contain exactly three characters and all other slices must contain exactly two characters.
For example, the word "Madison" has the slices "MAD", "IS", and "ON".
The array that is returned by this method must contain the appropriate number of slices, no more and no fewer.
Note that, though the game has the modifier "little" in its name, this method must work correctly for any parameter that has two or more characters.
9 The WordClue Class
AWordClue
is a pair that contains a word along with its associated clue and slices.
The constructor must initialize all of the attributes in the obvious way, with two exceptions. When the word passed to the constructor is null
or has fewer than MIN_WORD_LENGTH
characters, the corresponding attribute must be set to "DEFAULT"
. Similarly, when the clue passed to the constructor is null
, or has no characters, or has more than MAX_CLUE_LENGTH
characters, the corresponding attribute must be set to "DEFAULT CLUE"
.
All of the methods that return a hint must return a String
that contains nothing but uppercase characters. (Hint: Look in the String
class for a method or methods that might be helpful.) On the other hand, the getClue()
and getWord()
methods must return the corresponding attribute "as is".
Each of the toString()
methods must return a String
representation of the WordClue
. The version that is passed a boolean
parameter named verbose
behaves differently depending on the value of verbose
. When verbose
is false the String
it returns must consist of a single "line" (terminated by a '\n'
character) that contains the word
, followed by a dash (i.e., a '-'
character), followed by the clue
. For example, toString(true)
for the WordClue
constructed from "madison" and "the university's namesake" must return madison-the university's namesake\n
.
On the other hand, when verbose
is true
the String
it returns must consist of two "lines" (each terminated by a '\n'
character). The first "line" must be the same as when verbose
is false
, and the second "line" must contain the slices, with a space between each pair. For example, toString(true)
for the WordClue
constructed from "madison" and "the university's namesake" must return madison-the university's namesake\nMAD IS ON\n
.
Finally, the toString()
method that has no parameters must return the verbose String
representation.
The equals()
method must return true
when the word
attribute of the two WordClue
objects contain the same characters, ignoring their case. (Hint: Look in the String
class for a method or methods that might be helpful.)
10 The GameInfo Class
TheGameInfo
class is an encapsulation of all of the information needed to play a game, including the information provided by the author of the game (stored in a WordClue[]
) and the calculated information (stored in a Slice[]
).
The constructor must read the information (provided by the author of the game) from the given file (using the FileUtilities
class), construct a WordClue
object from each line, and construct all of the Slice
objects for all of the words.
The isComplete()
method must return true
if the appropriate number of words/clues were read and must return false
otherwise.
The toString()
method must return a String
that consists of multiple "lines" (each terminated with a '\n'
character) satisfying the following specifications.
- The first line must contain the
String
literal"Cluelist"
. - The next
NUMBER_OF_WORDS
"lines" must contain the terse(which is the opposite of verbose)String
representations of theWordClue
objects. - The next "line" must be blank.
- The next "line" must contain the
String
literal"Slices"
. - The next "lines" must contain the
String
representation of all of the slices.
For example, the toString()
method must return the following String
for the game in net.txt
(where each "line" is on its own line).
Cluelist browser-it helps you surf the net bullock-The Net actress Sandra fault-result of serve into the net brooklyn-Nets home, in the NBA acrobat-performer with a safety net gross-net pay before withholdings imprecise-like one casting a wide net Slices BRO WS ER BUL LO CK FAU LT BR OO KL YN ACR OB AT GRO SS IMP REC ISE
11 Submission
You must submit a.zip
file named pa5.zip
that contains GameInfo.java
,SevenLittleWords.java
, Slice.java
, WordClue.java
, and WordUtilities.java
.12 Grading
Your submissions will be graded according to the following criteria.12.1 Part A
Part A accounts for 10 points of the total grade. You may attempt Part A multiple times but you may not complete it after the due date.Though Canvas will assess each question individually, Part A will be graded on an "all or nothing" basis. In other words, you must receive a grade of 10 from Canvas to get any credit for Part A.
12.2 Part B
Part B accounts for 90 points of the total grade, divided as follows:- Style: 10 points (All or Nothing; Mandatory)
Slice
: 10 pointsWordUtilities
: 30 pointsWordClue
: 20 pointsGameInfo
: 20 points
Note that the style criterion is mandatory for this assignment. This means that neither the correctness nor the quality of your code will be assessed if it does not conform to the style guide. Hence, if your code does not conform to the style guide you will receive a grade of 0 for Part B.
Note also that the correctness of some classes depends on the correctness of the others (e.g., WordClue
uses WordUtilities
and Slice
, GameInfo
uses WordClue
and Slice
). So, it is important that you get the "foundational" classes working correctly.
13 Some Advice
You should write and test one class at a time, and, within each class, you should write and test only a few methods at a time.Probably the best way to proceed is as follows.
- Write the
Slice
class. - Test the
use()
,reset()
andisUsed()
methods. - Test the
toString()
method. - Write the
WordUtilities
class. - Test the
slice()
method in theWordUtilities
class onString
objects of length 3, 4, 6, 8, and 11. - Write the constructor,
getClue()
, andgetWord()
methods of theWordClue
class. - Test those methods.
- Write the
equals()
method. - Test the
equals()
method. - Write the other "getters" in the
WordClue
class. - Test the other "getters" in the
WordClue
class. - Write the other
toString()
method in theWordClue
class. - Test the other
toString()
method in theWordClue
class. - Write the constructor and
isComplete()
method of theGameInfo
class. - Test the constructor and
isComplete()
method of theGameInfo
class. - Write the "getters" in the
GameInfo
class. - Test the "getters" in the
GameInfo
class. - Write the
toString()
method in theGameInfo
class. - Test the
toString()
method in theGameInfo
class. - Write
SevenLittleWords
class. - Test the complete product.
Copyright 2018