PROJECT: FlashCard Pro
Overview
FlashCardPro is a program to manage flash cards. A FlashCard essentially has two properties, a front and a back. There
are four types of card: FrontBack, MCQ, Java and JavaScript.
The app also has a review mode where users can test themselves with the cards they have created.
Cards can also easily be shared via a json file per deck of cards.
Each card exists in a deck. Decks and cards alike can be deleted, edited and created. Furthermore, any changes to cards or decks can be undone and redone (after an undo).
Code Contribution
-
[Major Contribution] Populated and maintained the parsing in the Logic Package.
-
Included the creation of most of the enumerations in Responses (but not the implementation).
-
-
[Major Contribution] Implemented the addition of MCQ and Flashcards via CLI.
-
[Major Contribution] Implemented Undo/Redo feature.
Documentation Contribution
Redoes the last undo : redo
This allows you to redo any undo that you had previously done. Please note that any alteration of a recovered deck from an Undo command will also reset the Redo history.
Format: redo
Example:
-
redo
Undo the last alteration to a deck : undo
This allows you to undo any changed you may have made to any deck. This includes the creation of a new deck, the addition/edit of any cards and the deletion of cards or decks.
Format: undo
Example:
-
undo
Q: I accidentally deleted a deck! What can I do now?
A: You can just use the Undo command to recover the lost deck!
Q: How many times can I use the Undo command sequentially?
A: The Undo command can be used to undo all deck alterations for this session. However, if you quit out of the app and reopen it, you will erase your history of Undos!
Q: If I use Undo and make changes to an old version of a deck, will redo recover my original deck before the Undo command?
A: Unfortunately, the original deck before the Undo is unrecoverable. As such, please be mindful of making any changes to a recovered deck as this will erase any version of decks before the Undo!
Q: Will I be able to review my mistakes after a test?
A: Yes! Test mode allows you to review all the questions in the test and even re-attempt them without changing your initial test score.
Logic component
API :
link:{repoURL}/src/main/java/dream/fcard/logic [Logic Package
]
The Logic package manages the internal logic of the application.
When the User passes in their commands from the Command Line, it is passed to the Responder
class via the method takeInput()
.
This then passes the input String to the Responses enumerations which will parse the String into the appropriate command.
While parsing, Responses
will consider 2 criteria:
-
Only the
Responses
that exist in theResponseGroup
matching theState.currState
StateEnum
will be considered. -
Only
Responses
with a regex that matches the input String will be considered.
As such, depending on the StateEnum
(a.k.a. the current 'mode' of the application), only some Responses
will be
considered. For simplicity’s sake, the Responses
that exist for each application 'mode' can be said to exist in a
specific bucket (when the application is in TEST
mode, the Responses
that exist in the Test bucket are TEST_NEXT
,
TEST_PREV
and TEST_EXIT
).
When the right command is found, the specific Responses
enumeration will execute its own ResponseFunc
, which is the
implementation of the specific command (eg a help
command will print out the appropriate help message for the user).
To assist with the running of certain commands, the HelpCommand
and CreateCommand
classes are used to abstract the logic
further.
Undo/Redo Commands
Undo and Redo are commands meant to reverse any alterations to the ArrayList
of Decks in State. As such, any mistake
can be easily recovered from.
Please refer to the following Use case for an example of the uses of Undo/Redo.
Use case for Undo/Redo
-
System: FlashCard Pro
-
Actor: User
-
Use case: Accidentally deleting the wrong deck and recovering it.
MSS:
-
The user creates 2 decks: Deck1 and Deck2.
-
The user wishes to delete Deck1, but accidentally deletes Deck2.
-
In order to recover Deck2, the user types in the command
undo
into the CLI. -
Deck2 is recovered.
Use case ends.
*Extensions:
-
a) The user decides that they prefer Deck2 to be deleted.
-
) The user types 'redo' into the CLI.
-
) Deck2 is deleted again.
-
Use case ends.
General Activity Diagram of Undo/Redo
Before an Undo/Redo command is called:
Whenever the State’s `decks
are altered, State.addCurrDecksToDeckHistory()
is called. This adds a deep copy of the
current State.decks
to State.deckHistory
. Also, State.resetUndoHistory()
which re-initialises State.undoHistory
.
Then, the changes to State are carried out.
When an Undo/Redo command is called:
Note
|
The Undo and Redo commands are implemented in similar ways. As such, I will be explaining both commands simultaneously. |
When an Undo/Redo command is parsed by Responder and Responses, it calls the appropriate method in State
(for undo:
State.undoDeckChanges()
, for redo: State.redoDeckChanges()
). This then sets State.deck
to the topmost ArrayList
of Decks from the appropriate Stack (for undo: State.deckHistory
, for redo: State.undoHistory
).