Description
Problem statement: A GameParlor offers two types of
WordGames. CountGame allows the player to guess a word
in MAX_COUNT chances. TimeGame allows the payer to
guess aword in MAX_TIME seconds. The player chooses one
of the two games and then enters characters (a to z) to make
the guesses. Various input-output scenarios are shown
elow. The words to be guessed are chosen from a text file
miniwords.txt.
*** Enter your choice ***
1. Guess the Word in 10
counts
2. Guess the Word in 10
. seconds
*** Enter your choice *** 1
1. Guess the Word in 10 ]
Coulis Enter our guess!
2. Guess the Word in 10 yours ’
seconds g
1 1. [5 5 -]
k
[- 5 5 Ty Ty 5 -] 2. [- - -]
Enter your guess!
. w
3.[5--
1. [a, Ty Ty 5 5 Ty -] | J
|
4.[- 1, -
2. [a, l, l, 5 5 Ty -] | J
g
51[-1,-
3. [a, 1, 1,- g, 5 -]
5 S
6.[- 1, -
4.[a, lle ge, -] [,-]
*** Enter your choice ***
1. Guess the Word in 10
counts
2. Guess the Word in 10
seconds
1
2.[a, 1,1, -]
gS
3.[a,L,1,-8--]
e
4.[a,1,1,e,ge-]
d
5.[a,1,1,e, ged]
Great! You got it right in 5
guesses
Scenario 1: CountGame
won
2. Guess the Word in 10
seconds
1
[3+
Enter your guess!
gS
1.[---]
k
2.[---]
w
3.[+--]
|
4.[-1,-]
i
5.0-1,-]
gS
6.[-1,-]
p
7.[-1,-]
i
8.[-1,-]
w
9.[-1,-]
a
10.[a, I, -]
So
y! The word is ale
Scenario 2: CountGame
lost
*** Enter your choice ***
1 Guece the Wordin 10
*** Enter your choice ***
*** Enter your choice ***
1. Guess the Word in 10
counts
2. Guess the Word in 10
seconds
2
3
Enter your guess!
a
[3,~-]
1 seconds
g
[a,- -]
4 seconds
[a], -]
6 seconds
©
[a,1, €e]
8 seconds
Great! You got it right in 8
seconds
Scenario 3: TimeGame
won
*** Enter your choice ***
1. Guess the Word in 10
counts
2. Guess the Word in 10
seconds
Enter your guess!
S
[5 HS g, -]
1 seconds
S
[5 HS g, -]
4 seconds
k
[5 HS g, -]
6 seconds
t
[5 HS g, -]
9 seconds
Ww
[5 HS g, -]
11 seconds
So
y! The word is allege
Scenario 4: TimeGame
lost
age
ale
all
allege
alleged
miniwords.txt
Solution Design
The design has 4 classes, two of which are partially coded.
Please refer to the comments in the code files provided fo
more details. You need to create CountGame and
TimeGame. These two classes implement the play() method
differently. CountGame's play() method plays the game. It
takes user input for next guess and then invokes
getNextClue(), which returns a clue string which is eithe
same as before if the guess was wrong, or an updated clue
with co
ect guess inserted. This is repeated till either the
count reaches MAX_COUNT, or the flag isGameOver is true.
If isGameOver is true before reaching MAX_COUNT, it
means that the player has won,
The approach in TimeGame's play() method is the same
except that it checks system clock after every round. It uses
System.cu
entTimeMillis() to capture system time and
keeps checking after every guess made by the player. When
elapsed time exceeds MAX_TIME seconds, the game ends. If
isGameOver is true before reaching MAX_TIME, it means
that the player has won,
MAX_TIME: int =10
© CountGame
TimeGame(words: String(])
play(): void
MAX_COUNT: int =10
CountGame(words: String[])
play(): void
Design constraint: Use of collection classes not allowed.
No hardcoding.
Instructions
® Download the following files and copy/import them in
exam?2 package
o GameParlor.java
o WordGame.java
o TestGameParlor.java
® Copy/import the following file in your project
© miniwords.txt
® Complete your code as needed
® Write your name and Andrewld in both java files, zip
them as Andrewld-exam2.zip and submit