Skip to content

Commit

Permalink
Merge pull request #519 from yixiann/minor-fix
Browse files Browse the repository at this point in the history
Fix minor errors
  • Loading branch information
RichDom2185 authored Nov 6, 2022
2 parents 6ccb4a9 + fff2c05 commit be20005
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
29 changes: 17 additions & 12 deletions src/main/java/seedu/foodrem/commons/enums/CommandType.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ public String getUsage() {
@Override
public String getUsage() {
return getCommandWord() + ": Displays help for FoodRem.\n\n"
+ "Format:\n"
+ getCommandWord() + " [COMMAND_WORD]\n\n"
+ "Example:\n"
+ getCommandWord();
+ getCommandWord() + "\n"
+ getCommandWord() + " new";
}
},
RESET_COMMAND("reset") {
Expand Down Expand Up @@ -79,7 +82,7 @@ public String getUsage() {
+ "[" + PREFIX_ITEM_UNIT + "UNIT] "
+ "[" + PREFIX_ITEM_BOUGHT_DATE + "BOUGHT_DATE] "
+ "[" + PREFIX_ITEM_EXPIRY_DATE + "EXPIRY_DATE] "
+ "[" + PREFIX_ITEM_PRICE + "PRICE]"
+ "[" + PREFIX_ITEM_PRICE + "PRICE] "
+ "[" + PREFIX_ITEM_REMARKS + "REMARKS]\n\n"
+ "Examples:\n"
+ getCommandWord() + " 1 "
Expand All @@ -106,7 +109,7 @@ public String getUsage() {
FIND_COMMAND("find") {
@Override
public String getUsage() {
return getCommandWord() + ": Finds all items in FoodRem whose names contain substrings of any of "
return getCommandWord() + ": Finds all items in FoodRem whose names contain substrings of "
+ "the KEYWORDS (case-insensitive).\n\n"
+ "Format:\n"
+ getCommandWord() + " KEYWORD [KEYWORDS]...\n\n"
Expand Down Expand Up @@ -147,7 +150,7 @@ public String getUsage() {
+ "[" + PREFIX_ITEM_UNIT + "UNIT] "
+ "[" + PREFIX_ITEM_BOUGHT_DATE + "BOUGHT_DATE] "
+ "[" + PREFIX_ITEM_EXPIRY_DATE + "EXPIRY_DATE] "
+ "[" + PREFIX_ITEM_PRICE + "PRICE]"
+ "[" + PREFIX_ITEM_PRICE + "PRICE] "
+ "[" + PREFIX_ITEM_REMARKS + "REMARKS]\n\n"
+ "Examples:\n"
+ getCommandWord() + " "
Expand All @@ -156,19 +159,21 @@ public String getUsage() {
+ PREFIX_NAME + "Potatoes "
+ PREFIX_ITEM_QUANTITY + "10 "
+ PREFIX_ITEM_UNIT + "kg "
+ PREFIX_ITEM_BOUGHT_DATE + "11-11-2022 "
+ PREFIX_ITEM_EXPIRY_DATE + "21-11-2022 "
+ PREFIX_ITEM_PRICE + "10"
+ PREFIX_ITEM_BOUGHT_DATE + "11-10-2022 "
+ PREFIX_ITEM_EXPIRY_DATE + "21-10-2022 "
+ PREFIX_ITEM_PRICE + "10 "
+ PREFIX_ITEM_REMARKS + "For Salad";
}
},
REMARK_COMMAND("rmk") {
@Override
public String getUsage() {
return getCommandWord() + ": Adds a remark to " + THE_ITEM_IN_LIST
+ "Parameters: "
+ PREFIX_ITEM_REMARKS
+ "Example: " + getCommandWord() + " 1" + PREFIX_ITEM_REMARKS + "For oranges";
+ "\nFormat:\n"
+ getCommandWord() + " INDEX [" + PREFIX_ITEM_REMARKS + "REMARKS]\n\n"
+ "Examples:\n"
+ getCommandWord() + "\n"
+ getCommandWord() + " 1 " + PREFIX_ITEM_REMARKS + "For oranges";
}
},
SORT_COMMAND("sort") {
Expand All @@ -184,7 +189,7 @@ public String getUsage() {
+ "[" + PREFIX_ITEM_UNIT + "] "
+ "[" + PREFIX_ITEM_BOUGHT_DATE + "] "
+ "[" + PREFIX_ITEM_EXPIRY_DATE + "] "
+ "[" + PREFIX_ITEM_PRICE + "]"
+ "[" + PREFIX_ITEM_PRICE + "] "
+ "[" + PREFIX_ITEM_REMARKS + "]\n\n"
+ "Examples:\n"
+ getCommandWord() + " " + PREFIX_NAME + "\n"
Expand Down Expand Up @@ -242,7 +247,7 @@ public String getUsage() {
@Override
public String getUsage() {
return getCommandWord() + ": Renames an existing tag in FoodRem.\n\n"
+ "Format (Original Tag: First TAG_NAME. Renamed Tag: Second TAG_NAME):\n"
+ "Format (Original Tag: First TAG_NAME. Renamed Tag: Second TAG_NAME.):\n"
+ getCommandWord() + " "
+ PREFIX_NAME + "TAG_NAME "
+ PREFIX_NAME + "TAG_NAME\n\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class HelpCommand extends Command {
+ "in the command box, where COMMAND_WORD is any one of the following:\n"
+ CommandType.listAllCommandWords() + ".\n\n"
+ MORE_INFORMATION;
public static final String NOT_A_COMMAND = "\"%s\" is not a valid command\n\n" + HELP_FORMAT_GENERAL;
public static final String NOT_A_COMMAND = "\"%s\" is not a valid command.\n\n" + HELP_FORMAT_GENERAL;
private static final String SHOWING_HELP_MESSAGE = "Opened help window.";
private static final String HELP_FORMAT_SPECIFIC = "%s\n\n" + HELP_FORMAT_GENERAL;

Expand Down
18 changes: 11 additions & 7 deletions src/main/java/seedu/foodrem/views/StatsView.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package seedu.foodrem.views;

import java.text.DecimalFormat;
import java.util.List;
import java.util.stream.Collectors;

import javafx.geometry.Pos;
import javafx.scene.Node;
Expand All @@ -20,7 +22,7 @@
*/
public class StatsView {
private static final double SPACING_UNIT = 8;

private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00");
/**
* Creates a new detailed view of the given item.
*
Expand All @@ -36,7 +38,8 @@ public static Node from(Stats stats) {

// Section for amount wasted due to expired food
final Label amountWastedLabel = new Label("Total cost incurred due to food wastage:");
final Label amountWastedValue = new Label("$" + stats.getAmountWasted());
String amountWasted = DECIMAL_FORMAT.format(stats.getAmountWasted());
final Label amountWastedValue = new Label("$" + amountWasted);
amountWastedValue.getStyleClass().add("bold");
amountWastedLabel.setWrapText(true);

Expand Down Expand Up @@ -65,12 +68,13 @@ public static Node from(Stats stats) {
return statsView;
}

private static Node[] buildTopThreeMostExpensiveItemsListFrom(Stats stats) {
private static List<Node> buildTopThreeMostExpensiveItemsListFrom(Stats stats) {
List<Item> expensiveItems = stats.getTopThreeMostExpensiveItems();
Node[] nodes = expensiveItems.stream().map(ItemView::from)
.peek(node -> node.setStyle("-fx-padding: 20 0 0 0")).toArray(Node[]::new);
nodes[0].setStyle("-fx-padding: 0");
List<Node> nodes = expensiveItems.stream().map(ItemView::from)
.peek(node -> node.setStyle("-fx-padding: 20 0 0 0")).collect(Collectors.toList());
if (!nodes.isEmpty()) {
nodes.get(0).setStyle("-fx-padding: 0");
}
return nodes;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ class HelpCommandTest {
@Test
void getCommandHelpMessage() {
String helpMessage = "help: Displays help for FoodRem.\n\n"
+ "Format:\n"
+ "help [COMMAND_WORD]\n\n"
+ "Example:\n"
+ "help\n\n"
+ "help\n"
+ "help new\n\n"
+ "To receive help for a specific command, enter \"help COMMAND_WORD\" "
+ "in the command box, where COMMAND_WORD is any one of the following:\n"
+ "exit, help, reset, dec, del, edit, filtertag, find, inc, list, new, rmk, sort, view, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void parse_text() {
assertEquals(EXPECTED_ALL_COMMANDS, CommandType.listAllCommandWords());

// Not a command constant
assertEquals("\"testing\" is not a valid command\n\n"
assertEquals("\"testing\" is not a valid command.\n\n"
+ "To receive help for a specific command, enter "
+ "\"help COMMAND_WORD\" in the command box, where COMMAND_WORD is any one of the following:\n"
+ EXPECTED_ALL_COMMANDS
Expand Down

0 comments on commit be20005

Please sign in to comment.