Skip to content

Commit

Permalink
update help command list for all modes
Browse files Browse the repository at this point in the history
  • Loading branch information
exuberant-duck committed Oct 28, 2020
1 parent e5e4078 commit 15b5125
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 70 deletions.
4 changes: 3 additions & 1 deletion data/deckList.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
deck | 0
name | Micro-Economics
tags | Economics | EC1301
size | 4
size | 5
Q | What is the Law of demand?
A | When the price of a good rises, the quantity of the good demanded will fall, ceteris paribus.
Q | What is the Law of supply?
Expand All @@ -10,6 +10,8 @@ Q | What is price elasticity of demand?
A | Percentage change in quantity demanded caused by a 1 percent change in price.
Q | What is price elasticity of supply?
A | Percentage change in quantity supplied caused by a 1 percent change in price.
Q | What is Market Failure?
A | Market failure is the economic situation defined by an inefficient distribution of goods and services in the free market.
================================================================================
deck | 1
name | Macro-Economics
Expand Down
4 changes: 2 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ Starts Game Mode for the current deck.

```java
[Deck - market-failure]
> start
> start
```

#### Examples
Expand All @@ -615,7 +615,7 @@ Starts Game Mode for the current deck.
// ...
// ------------------------------------------------------------
[Deck - market-failure]
> start 1
> start
// ------------------------------------------------------------
// Welcome to Game Mode!
//
Expand Down
Binary file modified pptx/Micro-Economics.pptx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/seedu/ecardnomics/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class Main {

public static final double VERSION_NUMBER = 1.0;
public static final double VERSION_NUMBER = 2.0;
public static DeckList deckList = new DeckList();
public static NormalParser normalParser = new NormalParser(deckList);
public static Storage storage = new Storage();
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/seedu/ecardnomics/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Ui {
public static final String LIST_FLASHCARDS_LINE =
"You are now viewing deck: ";
public static final String DELETE_FLASHCARD_LINE =
"Do you want to delete the following flash card? ";
"Do you want to delete the following flash card? [y/n] ";
public static final String FLASHCARD_DELETED_LINE =
"The following flash card has been deleted:\n '";
public static final String NEW_DECK_CREATED_LINE =
Expand All @@ -48,7 +48,7 @@ public class Ui {
public static final String DELETED_DECK_LINE =
"%1$s has been deleted.";
public static final String PPTX_DECK_QUESTION_LINE =
"Do you want to print %1$s deck to PowerPoint? [y/n]\n > ";
"Do you want to print %1$s deck to PowerPoint? [y/n] ";
public static final String PPTX_DECK_LINE =
"%1$s has been created as PowerPoint.";
public static final String INVALID_YN_RESPONSE_LINE =
Expand All @@ -58,7 +58,7 @@ public class Ui {
private static final String NEW_TAGS_LINE =
"The deck %1$s has been tagged as: %2$s";
private static final String REMOVED_TAGS_QUESTION_LINE =
"Do you want to remove the tag(s) %1$s from %2$s? [y/n]";
"Do you want to remove the tag(s) %1$s from %2$s? [y/n] ";
private static final String REMOVED_TAGS_LINE =
"The tag(s) %1$s have been removed from the deck %2$s.";
private static final String NEW_QUESTION_LINE =
Expand All @@ -74,7 +74,7 @@ public class Ui {
private static final String NO_UPDATE_LINE =
"Original question and answer retained";
private static final String INCLUDE_EXCLUDE_LINE =
"Do you want to re-attempt this question later? ";
"Do you want to re-attempt this question later? [y/n] ";
private static final String ATTEMPT_FEEDBACK_LINE =
"The score for your answer is:";
private static final String ENTER_ATTEMPT_LINE =
Expand Down Expand Up @@ -278,8 +278,7 @@ public static void printDeck(Deck deck, boolean isQuestionOnly) {
* @param question The question of the FlashCard to delete
*/
public static void printDeleteFlashCardLine(String question) {
System.out.print(DELETE_FLASHCARD_LINE + YN_LINE + "?\n '" + question + "`\n");
printPrompt();
System.out.print(DELETE_FLASHCARD_LINE + "?\n '" + question + "' ");
}

/**
Expand Down Expand Up @@ -416,14 +415,19 @@ public static void printVersionNumber() {
}

public static void printIncludeExcludeLine() {
System.out.print(INCLUDE_EXCLUDE_LINE + YN_LINE + "\n");
printPrompt();
System.out.print(INCLUDE_EXCLUDE_LINE);
}

public static void printAttemptFeedback(double matchPercentage) {
System.out.println(String.format("%s %.2f", ATTEMPT_FEEDBACK_LINE, matchPercentage));
}

public static boolean getInclExclConfirmation() {
logger.log(Level.INFO, "Logging method getInclExclConfirmation() in Ui.");
Ui.printIncludeExcludeLine();
return checkYorNResponse();
}

public static void printGameQuestion(String question) {
System.out.println("Q: " + question);
System.out.println(ENTER_ATTEMPT_LINE);
Expand Down Expand Up @@ -469,7 +473,7 @@ public static void printInvalidTagsLine() {
*/
public static void printRemovedTagsQuestion(String deckName, String[] tags) {
String removedTags = formStringOfTags(tags);
System.out.println(String.format(REMOVED_TAGS_QUESTION_LINE, removedTags, deckName));
System.out.print(String.format(REMOVED_TAGS_QUESTION_LINE, removedTags, deckName));
}

/**
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/seedu/ecardnomics/command/deck/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ public class HelpCommand extends DeckCommand {
+ "Deck Mode.\n"
+ "\n"
+ "Usage:\n"
+ " add Adds a new flash card to the current deck.\n"
+ " list [/ans] Lists all flash cards in the current deck, optionally with answers.\n"
+ " delete <ix> Deletes the flash card at list index <ix> from the current deck.\n"
+ " pptx [-y] Creates a PowerPoint slides based on the current deck.\n"
+ " done Exits from Deck Mode and returns to Normal Mode.\n"
+ " exit Exits the program.\n"
+ " help Show this output.\n"
+ " add [<qn> /ans <ans>] Adds a new flash card to the current deck.\n"
+ " list [/ans] Lists all flash cards in the current deck, optionally with answers.\n"
+ " delete <ix> [-y] Deletes the flash card at list index <ix> from the current deck.\n"
+ " pptx [-y] Creates a PowerPoint slides based on the current deck.\n"
+ " start Enter Game Mode for this deck! Do your best!\n"
+ " done Exits from Deck Mode and returns to Normal Mode.\n"
+ " exit Exits the program.\n"
+ " help Show this output.\n"
+ "\n"
+ "Options:\n"
+ " --version Show version.";
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/seedu/ecardnomics/command/normal/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ public class HelpCommand extends NormalCommand {
+ "Normal Mode.\n"
+ "\n"
+ "Usage:\n"
+ " create <nm> Creates a new deck of flash cards, named <nm>.\n"
+ " decks Lists all available decks.\n"
+ " edit <ix> Enter Deck Mode for editing the deck at list index <ix>.\n"
+ " start <ix> Enter Game Mode for deck at list index <ix>! Do your best!\n"
+ " delete <ix> Deletes the deck at list index <ix> from list of decks.\n"
+ " pptx <ix> [-y] Creates a PowerPoint slides based on the deck at list index <ix>.\n"
+ " exit Exits the program.\n"
+ " help Show this output.\n"
+ " create <nm> [/tag <tag1> [<tag2> ...]] Creates a new deck of flash cards, named <nm>.\n"
+ " decks Lists all available decks.\n"
+ " edit <ix> Enter Deck Mode for editing the deck at list index <ix>" +
".\n"
+ " start <ix> Enter Game Mode for deck at list index <ix>! Do your " +
"best!\n"
+ " delete <ix> [-y] Deletes the deck at list index <ix> from list of decks.\n"
+ " pptx <ix> [-y] Creates a PowerPoint slides based on the deck at list " +
"index <ix>.\n"
+ " tag <ix> /tag <tag1> [<tag2> ...] Tags the deck at list index <ix>, with 1 or more tags.\n"
+ " untag <ix> /tag <tag1> [<tag2> ...] Untags specified <tag>s of the deck at list index <ix>.\n"
+ " search <tag1> [<tag2> ...] Search deck list for decks tagged with specified <tag>s.\n"
+ " exit Exits the program.\n"
+ " help Show this output.\n"
+ "\n"
+ "Options:\n"
+ " --version Show version.";
Expand Down
24 changes: 7 additions & 17 deletions src/main/java/seedu/ecardnomics/game/GameEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ Command runGameLoop() {
} catch (Exception e) {
e.getMessage();
}
command = update(getInclExclYorNResponse(), flashCard, command);
command = update(Ui.getInclExclConfirmation(), flashCard, command);

} while (!isTerminate(command) && !isNoMoreCards());

return command;
}

Command update(String response, FlashCard flashCard, Command command) {
Command update(boolean isResponseY, FlashCard flashCard, Command command) {
assert !isTerminate(command) : "Command is either `done` or `exit` when it shouldn't be!";

updateRetestStore(response, flashCard);
updateRetestStore(isResponseY, flashCard);

if (storage.deque.isEmpty()) {
if (storage.retestStore.isEmpty()) {
Expand All @@ -73,22 +73,16 @@ void updateDeque() {
storage.refreshRetestStore();
}

void updateRetestStore(String response, FlashCard flashCard) {
switch (response) {
// include
case Ui.Y:
void updateRetestStore(boolean response, FlashCard flashCard) {
if (response) {
if (!storage.retestStore.contains(flashCard)) {
storage.retestStore.add(flashCard);
}
break;
// exclude
case Ui.N:
} else {

if (!storage.retestStore.contains(flashCard)) {
storage.retestStore.remove(flashCard);
}
break;
default:
//
}
}

Expand All @@ -100,10 +94,6 @@ void poseQuestion(FlashCard flashCard) {
Ui.printGameQuestion(flashCard.getQuestion());
}

String getInclExclYorNResponse() {
return gameParser.getInclExclYorNResponse();
}

Command getAttempt() {
String userInput = Ui.readUserInput();
Command command = gameParser.parse(userInput);
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/seedu/ecardnomics/parser/GameParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,6 @@ protected int getIndex(String arguments) throws IndexFormatException, FlashCardR
return index;
}

public String getInclExclYorNResponse() {
String response = "";

Ui.printDashLines();
do {
Ui.printIncludeExcludeLine();
response = Ui.readUserInput();
Ui.printDashLines();
switch (response.trim()) {
case Ui.Y:
response = Ui.Y;
break;
case Ui.N:
response = Ui.N;
break;
default:
logger.log(Level.INFO, "User entered response other than 'Y' or 'N'");
Ui.printInvalidYorNResponse();
logger.log(Level.INFO, "Re-prompting...");
}
} while (!response.trim().equals(Ui.Y) && !response.trim().equals(Ui.N));
assert response.length() == 1 : "response is not 'Y' or 'N'!";
return response;
}

@Override
protected Command parseCommand(String commandWord, String arguments) {

Expand Down

0 comments on commit 15b5125

Please sign in to comment.