Skip to content

Commit

Permalink
Merge pull request #372 from Ferusel/tingkai/fix-stats-command
Browse files Browse the repository at this point in the history
Fix stats command
  • Loading branch information
tingkai-mai authored Oct 28, 2022
2 parents d55bf49 + 7013251 commit 46adb0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
23 changes: 12 additions & 11 deletions docs/_ug/commands/StatisticsCommands.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!-- markdownlint-disable-file first-line-h1 -->
#### Display statistics: `stats`

<!-- TODO: Update after Richard's PR on statistics -->

**Format**: `stats`

> Displays relevant statistics collected by FoodRem.
```note
These statistics include:
* Items that expire within the next 10 days
* Total cost of wasted items
* Most expensive item in your inventory
* Top 3 most commonly used tags in your inventory
* Top 3 most costly items in your inventory
The cost of an item is the price of the item multiplied by the number of those items in your inventory.
```

**Example Input:**
Expand All @@ -25,15 +25,16 @@ stats
Command Output Box:

```text
Items that expire within the next 10 days:
1. Onions 8 kg $1 (Bought Date: 10-10-2022) (Expiry Date: 10-11-2022)
2. Chicken 30 kg $4.20 (Bought Date: 10-10-2022) (Expiry Date: 15-10-2022)
3. Carrots 11 kg $0.60 (Bought Date: 10-10-2022) (Expiry Date: 26-10-2022)
Statistics
Total cost of wasted items:
$120
Most expensive item in your inventory:
Chicken 30 kg $4.20 (Bought Date: 10-10-2022) (Expiry Date: 15-10-2022)
Top 3 common tags:
Drinks Fridge Fruits
Your top 3 items with highest value are as follows:
1. Onions 8 kg $1 (Bought Date: 10-10-2022) (Expiry Date: 10-11-2022)
2. Chicken 30 kg $4.20 (Bought Date: 10-10-2022) (Expiry Date: 15-10-2022)
3. Carrots 11 kg $0.60 (Bought Date: 10-10-2022) (Expiry Date: 26-10-2022)
```
2 changes: 1 addition & 1 deletion src/main/java/seedu/foodrem/model/item/ItemPrice.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Guarantees: details are present and not null, field values are validated, immutable.
*/
public class ItemPrice {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.00");
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00");
private static final double DEFAULT_PRICE = 0;

private final double itemPrice;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/foodrem/views/ItemView.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static Node from(Item item) {
final Label priceValue = new Label(item.getPrice().toString());
priceValue.getStyleClass().add("bold");
final Label costLabel = new Label("Total Cost: $");
final Label costValue = new Label(String.valueOf(item.getItemCost()));
final Label costValue = new Label(String.format("%.2f", item.getItemCost()));
costValue.getStyleClass().add("bold");

final Label remarks = new Label(item.getRemarks().toString().isBlank() ? "-" : item.getRemarks().toString());
Expand Down

0 comments on commit 46adb0f

Please sign in to comment.