Here is a quick overview of the main components and how they interact with each other:
Parser Class (v2.1) reads user input from the standard input stream, checks the input, tests the validity, and conveys the validity back to the class it is called from.
Briefly, the Parser class interacts with the main program by reading the inputs and throwing exceptions or returning specific values if the inputs are unexpected. This behavior is then handled by the Duke class or TicTacToe class. Parser also screens for the content of the input, specifically if the content is one of the non-gaming commands such as ‘quit’ or ‘help’
The UI
consists of three classes: Ui.java
, Render.java
, and TimerTutorial.java
.
The (partial) class diagram is illustrated below:
Render.java
and TimerTutorial.java
. These
methods are extracted to display various types of messages and art. These include greetUser()
,
quitUser()
, printHelp()
, printTTTTutorial()
, printHangmanTutorial()
, and println()
greetUser()
and quitUser()
displays the greetings and randomised farewells, including art.printHelp()
prints the descriptive help message.printTTTTutorial()
and printHangmanTutorial()
displays a gameplay tutorial of each game, displaying a frame
every 4 seconds.println()
is a simple and convenient method to call for other classes.Render Class: Contains all the art and messages that are called in Ui.java
displayTTTTutorial()
and displayHangmanTutorial()
which
displays every frame of the tutorial, and a schedule method scheduleTutorialFrames(frames, interval)
is used to
run()
a frame every 4 seconds.The UI
component,
Parser
component.Render
.tutorial
to assist user in TimerTutorial
.
java.util.Timer
and java.util.TimerTask
.scheduleTutorialFrames(frames, interval)
method automatically schedules and displays tutorial frames at fixed
intervals, in this case would be 4 secondsRender
in getHangmanFrames()
and getTTTFrames()
quit
) during the tutorial, quit
will exit the tutorial state.handleTutorial(displayMethod, tutorial name)
method in Ui
flags the boolean stopTutorial
as true if quit
is
typed. This cancels the timer in TimerTutorial
ensuring the exit of tutorial mode.A log file will also be made at FILE_PATH "./text-ui-test/UiLog.log"
at start of program via setupLogging()
in Ui
,
that records all Ui-related information and can be used for troubleshooting. The log file will refresh at every start.
JUnit testing for functionality testing can be found at UiTest.java
in ./src/main/test/java/seedu.duke
The Game
class, is the parent class for our games, TicTacToe
and Hangman
.
howToPlay
as rules guidelines for users for each respective game to teach users on the games ruleshowToPlay
also guides how the game would be controlled on the CLI.howToPlay
will be overridden by child classes, TicTacToe
and Hangman
.Game
type is created to store multiple instances of TicTacToe
and Hangman
to allow many rounds
of either games to be played.Game
has variable gameOutcome
which ranges from 0 to 3. 0
denotes the game was lost, while 1
denotes a win, 2
is draw (only applicable for TTT) and lastly, 3
when a game is quit upon without finishing.gameOutcome
is initialized to be 0 (game lost). Meanwhile, the methods gameWon
, gameQuit
and gameDraw
will change gameOutcome
based on the actual in-game outcome.stats
command is called in the CLI, the program iterates through the ArrayList of Game
, then computes and outputs the player’s statistics.The TicTacToe
class, which inherits from the Game
class, handles the Tic-Tac-Toe game itself!
The TicTacToe
class:
Scanner
, after which the input is parsed by the Parser
class.
1
to 9
.board
upon which the game is played on.
board
is a String
array
with 9
slots, indicating the possible inputs from the user.board
is also printed at the start of the game and after every move by the user.TTT
algorithm in computerBestMove(String[] board, int turnCount)
, and should the player choose to play against the hard
computer, they will never win.
easy
mode, which is really just randomly populating the board.checkWinner(int turnCount)
method, which takes in the number of turns taken so far.
unending
if the game is unfinished or the user inputs quit
.X
if the user wins the gameO
if the user loses the gamedraw
if the user and the computer drawui
elements that improve player interaction and engagement!The HangMan
class:
runHangMan
is called.Scanner
.
wordBank
which contains the list of available words randomly selected for the hangman game.chosenWordLength
based on the randomly chosenWord
.chosenWord
to check for similar letters used.
Each iteration of user input will result in calls of addGuess
, printHangMan
, printLettersGuessed
& printWordGuesser
.
addGuess
adds the user input to an arraylistprintLettersGuessed
then iterates through allGuessedLetters
, printing each element of the array list._
blank spaces corresponding to letters not yet guessed, are printed using printWordGuesser
.state
increasing by 1.
printHangMan
prints a different hangman based on the game state
.state
reach 6, the game is lost.runHangMan
checks for the number of _
blank spaces left at each iteration of user input.
_
be 0, the player has won.Storage Class is intended to load and save statistics, such as player name and number of wins, to a data file. Currently, this is unimplemented for its purpose. We plan to further develop this feature in a future release.
This Sequence Diagram illustrates an overview of how the different classes interact with each other in the main game loop.
CLI-based games work on different operating systems and environments that support command-line interfaces. This means players can enjoy the game no matter what kind of computer or setup they use.
Version | As a … | I want to … | So that I can … |
---|---|---|---|
v1.0 | new user | see program instructions | refer to them when I forget commands to navigate the gaming application |
v1.0 | lazy person | play a game entirely with keys on my keyboard | minimize movement while playing |
v1.0 | user | play a game of Hangman | occupy myself with a harder, more engaging word-based game while travelling |
v1.0 | user | play a game of Tic Tac Toe | occupy myself with an easy, mindless game while travelling |
v1.0 | child | play these games peacefully on my own | leave my parents alone while we’re travelling |
v1.0 | user | quit a game whenever I want | try again, or give up and relax |
v1.0 | user | play at my own pace | multitask and do other things while gaming during my trip |
v2.0 | unfamiliar player | see a dynamic gaming step-by-step tutorial | see visually how to play both games |
v2.0 | user | choose a difficulty level in Tic Tac Toe | decide how challenged I want to feel in this game |
v2.0 | user | choose a theme of words in Hangman | have a more cohesive and organized experience while playing Hangman, and have more control |
v2.0 | user | see gaming guide while in Tic Tac Toe/Hangman | recall how the game works without exiting to view the tutorial and returning again |
v2.0 | competitive player | see how many games I’ve won and lost | challenge myself to winning more games |
v2.0 | traveller | play all these games without internet connection | locate a to-do without having to go through the entire list |
v2.0 | user | see my past moves and retrace | find new strategies to win |
v2.0 | user | be prompted when I repeat the same attempts | not lose points/tries because I forgot my past attempts |
Java 11
installed.AeroCade.jar
file from GitHub.cd
into the folder you put the game file in.java -jar AeroCade.jar
to run the game!quit
to exit the game.Now what would you like to do?
, type quit
again to exit the program.