Skip to content

Commit 15b5125

Browse files
committed
update help command list for all modes
1 parent e5e4078 commit 15b5125

File tree

9 files changed

+48
-70
lines changed

9 files changed

+48
-70
lines changed

data/deckList.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
deck | 0
22
name | Micro-Economics
33
tags | Economics | EC1301
4-
size | 4
4+
size | 5
55
Q | What is the Law of demand?
66
A | When the price of a good rises, the quantity of the good demanded will fall, ceteris paribus.
77
Q | What is the Law of supply?
@@ -10,6 +10,8 @@ Q | What is price elasticity of demand?
1010
A | Percentage change in quantity demanded caused by a 1 percent change in price.
1111
Q | What is price elasticity of supply?
1212
A | Percentage change in quantity supplied caused by a 1 percent change in price.
13+
Q | What is Market Failure?
14+
A | Market failure is the economic situation defined by an inefficient distribution of goods and services in the free market.
1315
================================================================================
1416
deck | 1
1517
name | Macro-Economics

docs/UserGuide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ Starts Game Mode for the current deck.
602602

603603
```java
604604
[Deck - market-failure]
605-
> start
605+
> start
606606
```
607607

608608
#### Examples
@@ -615,7 +615,7 @@ Starts Game Mode for the current deck.
615615
// ...
616616
// ------------------------------------------------------------
617617
[Deck - market-failure]
618-
> start 1
618+
> start
619619
// ------------------------------------------------------------
620620
// Welcome to Game Mode!
621621
//

pptx/Micro-Economics.pptx

-64 Bytes
Binary file not shown.

src/main/java/seedu/ecardnomics/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
public class Main {
2121

22-
public static final double VERSION_NUMBER = 1.0;
22+
public static final double VERSION_NUMBER = 2.0;
2323
public static DeckList deckList = new DeckList();
2424
public static NormalParser normalParser = new NormalParser(deckList);
2525
public static Storage storage = new Storage();

src/main/java/seedu/ecardnomics/Ui.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class Ui {
3636
public static final String LIST_FLASHCARDS_LINE =
3737
"You are now viewing deck: ";
3838
public static final String DELETE_FLASHCARD_LINE =
39-
"Do you want to delete the following flash card? ";
39+
"Do you want to delete the following flash card? [y/n] ";
4040
public static final String FLASHCARD_DELETED_LINE =
4141
"The following flash card has been deleted:\n '";
4242
public static final String NEW_DECK_CREATED_LINE =
@@ -48,7 +48,7 @@ public class Ui {
4848
public static final String DELETED_DECK_LINE =
4949
"%1$s has been deleted.";
5050
public static final String PPTX_DECK_QUESTION_LINE =
51-
"Do you want to print %1$s deck to PowerPoint? [y/n]\n > ";
51+
"Do you want to print %1$s deck to PowerPoint? [y/n] ";
5252
public static final String PPTX_DECK_LINE =
5353
"%1$s has been created as PowerPoint.";
5454
public static final String INVALID_YN_RESPONSE_LINE =
@@ -58,7 +58,7 @@ public class Ui {
5858
private static final String NEW_TAGS_LINE =
5959
"The deck %1$s has been tagged as: %2$s";
6060
private static final String REMOVED_TAGS_QUESTION_LINE =
61-
"Do you want to remove the tag(s) %1$s from %2$s? [y/n]";
61+
"Do you want to remove the tag(s) %1$s from %2$s? [y/n] ";
6262
private static final String REMOVED_TAGS_LINE =
6363
"The tag(s) %1$s have been removed from the deck %2$s.";
6464
private static final String NEW_QUESTION_LINE =
@@ -74,7 +74,7 @@ public class Ui {
7474
private static final String NO_UPDATE_LINE =
7575
"Original question and answer retained";
7676
private static final String INCLUDE_EXCLUDE_LINE =
77-
"Do you want to re-attempt this question later? ";
77+
"Do you want to re-attempt this question later? [y/n] ";
7878
private static final String ATTEMPT_FEEDBACK_LINE =
7979
"The score for your answer is:";
8080
private static final String ENTER_ATTEMPT_LINE =
@@ -278,8 +278,7 @@ public static void printDeck(Deck deck, boolean isQuestionOnly) {
278278
* @param question The question of the FlashCard to delete
279279
*/
280280
public static void printDeleteFlashCardLine(String question) {
281-
System.out.print(DELETE_FLASHCARD_LINE + YN_LINE + "?\n '" + question + "`\n");
282-
printPrompt();
281+
System.out.print(DELETE_FLASHCARD_LINE + "?\n '" + question + "' ");
283282
}
284283

285284
/**
@@ -416,14 +415,19 @@ public static void printVersionNumber() {
416415
}
417416

418417
public static void printIncludeExcludeLine() {
419-
System.out.print(INCLUDE_EXCLUDE_LINE + YN_LINE + "\n");
420-
printPrompt();
418+
System.out.print(INCLUDE_EXCLUDE_LINE);
421419
}
422420

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

425+
public static boolean getInclExclConfirmation() {
426+
logger.log(Level.INFO, "Logging method getInclExclConfirmation() in Ui.");
427+
Ui.printIncludeExcludeLine();
428+
return checkYorNResponse();
429+
}
430+
427431
public static void printGameQuestion(String question) {
428432
System.out.println("Q: " + question);
429433
System.out.println(ENTER_ATTEMPT_LINE);
@@ -469,7 +473,7 @@ public static void printInvalidTagsLine() {
469473
*/
470474
public static void printRemovedTagsQuestion(String deckName, String[] tags) {
471475
String removedTags = formStringOfTags(tags);
472-
System.out.println(String.format(REMOVED_TAGS_QUESTION_LINE, removedTags, deckName));
476+
System.out.print(String.format(REMOVED_TAGS_QUESTION_LINE, removedTags, deckName));
473477
}
474478

475479
/**

src/main/java/seedu/ecardnomics/command/deck/HelpCommand.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ public class HelpCommand extends DeckCommand {
88
+ "Deck Mode.\n"
99
+ "\n"
1010
+ "Usage:\n"
11-
+ " add Adds a new flash card to the current deck.\n"
12-
+ " list [/ans] Lists all flash cards in the current deck, optionally with answers.\n"
13-
+ " delete <ix> Deletes the flash card at list index <ix> from the current deck.\n"
14-
+ " pptx [-y] Creates a PowerPoint slides based on the current deck.\n"
15-
+ " done Exits from Deck Mode and returns to Normal Mode.\n"
16-
+ " exit Exits the program.\n"
17-
+ " help Show this output.\n"
11+
+ " add [<qn> /ans <ans>] Adds a new flash card to the current deck.\n"
12+
+ " list [/ans] Lists all flash cards in the current deck, optionally with answers.\n"
13+
+ " delete <ix> [-y] Deletes the flash card at list index <ix> from the current deck.\n"
14+
+ " pptx [-y] Creates a PowerPoint slides based on the current deck.\n"
15+
+ " start Enter Game Mode for this deck! Do your best!\n"
16+
+ " done Exits from Deck Mode and returns to Normal Mode.\n"
17+
+ " exit Exits the program.\n"
18+
+ " help Show this output.\n"
1819
+ "\n"
1920
+ "Options:\n"
2021
+ " --version Show version.";

src/main/java/seedu/ecardnomics/command/normal/HelpCommand.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ public class HelpCommand extends NormalCommand {
99
+ "Normal Mode.\n"
1010
+ "\n"
1111
+ "Usage:\n"
12-
+ " create <nm> Creates a new deck of flash cards, named <nm>.\n"
13-
+ " decks Lists all available decks.\n"
14-
+ " edit <ix> Enter Deck Mode for editing the deck at list index <ix>.\n"
15-
+ " start <ix> Enter Game Mode for deck at list index <ix>! Do your best!\n"
16-
+ " delete <ix> Deletes the deck at list index <ix> from list of decks.\n"
17-
+ " pptx <ix> [-y] Creates a PowerPoint slides based on the deck at list index <ix>.\n"
18-
+ " exit Exits the program.\n"
19-
+ " help Show this output.\n"
12+
+ " create <nm> [/tag <tag1> [<tag2> ...]] Creates a new deck of flash cards, named <nm>.\n"
13+
+ " decks Lists all available decks.\n"
14+
+ " edit <ix> Enter Deck Mode for editing the deck at list index <ix>" +
15+
".\n"
16+
+ " start <ix> Enter Game Mode for deck at list index <ix>! Do your " +
17+
"best!\n"
18+
+ " delete <ix> [-y] Deletes the deck at list index <ix> from list of decks.\n"
19+
+ " pptx <ix> [-y] Creates a PowerPoint slides based on the deck at list " +
20+
"index <ix>.\n"
21+
+ " tag <ix> /tag <tag1> [<tag2> ...] Tags the deck at list index <ix>, with 1 or more tags.\n"
22+
+ " untag <ix> /tag <tag1> [<tag2> ...] Untags specified <tag>s of the deck at list index <ix>.\n"
23+
+ " search <tag1> [<tag2> ...] Search deck list for decks tagged with specified <tag>s.\n"
24+
+ " exit Exits the program.\n"
25+
+ " help Show this output.\n"
2026
+ "\n"
2127
+ "Options:\n"
2228
+ " --version Show version.";

src/main/java/seedu/ecardnomics/game/GameEngine.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ Command runGameLoop() {
4444
} catch (Exception e) {
4545
e.getMessage();
4646
}
47-
command = update(getInclExclYorNResponse(), flashCard, command);
47+
command = update(Ui.getInclExclConfirmation(), flashCard, command);
4848

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

5151
return command;
5252
}
5353

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

57-
updateRetestStore(response, flashCard);
57+
updateRetestStore(isResponseY, flashCard);
5858

5959
if (storage.deque.isEmpty()) {
6060
if (storage.retestStore.isEmpty()) {
@@ -73,22 +73,16 @@ void updateDeque() {
7373
storage.refreshRetestStore();
7474
}
7575

76-
void updateRetestStore(String response, FlashCard flashCard) {
77-
switch (response) {
78-
// include
79-
case Ui.Y:
76+
void updateRetestStore(boolean response, FlashCard flashCard) {
77+
if (response) {
8078
if (!storage.retestStore.contains(flashCard)) {
8179
storage.retestStore.add(flashCard);
8280
}
83-
break;
84-
// exclude
85-
case Ui.N:
81+
} else {
82+
8683
if (!storage.retestStore.contains(flashCard)) {
8784
storage.retestStore.remove(flashCard);
8885
}
89-
break;
90-
default:
91-
//
9286
}
9387
}
9488

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

103-
String getInclExclYorNResponse() {
104-
return gameParser.getInclExclYorNResponse();
105-
}
106-
10797
Command getAttempt() {
10898
String userInput = Ui.readUserInput();
10999
Command command = gameParser.parse(userInput);

src/main/java/seedu/ecardnomics/parser/GameParser.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,6 @@ protected int getIndex(String arguments) throws IndexFormatException, FlashCardR
4747
return index;
4848
}
4949

50-
public String getInclExclYorNResponse() {
51-
String response = "";
52-
53-
Ui.printDashLines();
54-
do {
55-
Ui.printIncludeExcludeLine();
56-
response = Ui.readUserInput();
57-
Ui.printDashLines();
58-
switch (response.trim()) {
59-
case Ui.Y:
60-
response = Ui.Y;
61-
break;
62-
case Ui.N:
63-
response = Ui.N;
64-
break;
65-
default:
66-
logger.log(Level.INFO, "User entered response other than 'Y' or 'N'");
67-
Ui.printInvalidYorNResponse();
68-
logger.log(Level.INFO, "Re-prompting...");
69-
}
70-
} while (!response.trim().equals(Ui.Y) && !response.trim().equals(Ui.N));
71-
assert response.length() == 1 : "response is not 'Y' or 'N'!";
72-
return response;
73-
}
74-
7550
@Override
7651
protected Command parseCommand(String commandWord, String arguments) {
7752

0 commit comments

Comments
 (0)