From 9b61fb8746e9d1557c99bf86c4a542be5e5214ed Mon Sep 17 00:00:00 2001 From: DavidTay Date: Wed, 10 Apr 2024 10:35:38 +0800 Subject: [PATCH 1/2] add PPP --- docs/team/dtaywd.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs/team/dtaywd.md diff --git a/docs/team/dtaywd.md b/docs/team/dtaywd.md new file mode 100644 index 0000000000..55d977a71f --- /dev/null +++ b/docs/team/dtaywd.md @@ -0,0 +1,45 @@ +# Tay Wen Duan David Project Portfolio Page + +## Project: SuperTracker + +SuperTracker is a desktop app for managing a supermarket's inventory and expenditures, +optimized for use via a Command Line Interface (CLI). + +Given below are my contributions to the project. + +- **Feature:** Update Command + - What it does: Allows users to update the price, quantity and/or expiry date. + - Justification: A supermarket manager can make mistakes when adding items + and the app should provide a convenient way to rectify them, instead of manually deleting the item from the inventory + and adding it back in with a new price, quantity and/or expiry date. + - Highlights: Before creating a new update command, the parser helps to validate the users inputs by checking if the + numbers provided are negative or over the integer limit and whether the expiry date follows the correct date format. + +- **Feature:** Report Command + - What it does: Allows supermarket managers to see what items are low on stock and are close to expiry. + - Justification: A supermarket manager may want to see what items are low on stock or close to expiry, so that they + may make an order to replace them. + - Highlights: Report command handles two different types of reports with only 1 needing the optional parameter and + sorts the report based on quantity or expiry date for low stock and expiry report respectively. + +- **Feature:** Expenditure Command + - What it does: Allows supermarket managers to check their expenditures over a period of time. + - Justification: This function is necessary to see what is the cash outflow of the supermarket. Moreover, this + function is necessary to calculate the profit of the supermarket + - Highlights: The expenditure command unifies what the revenue commands uses to reduce the amount of repeated code. + + +- **Code contributed** [RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=dtaywd&breakdown=true&sort=groupTitle%20dsc&sortWithin=title&since=2024-02-23&timeframe=commit&mergegroup=&groupSelect=groupByRepos&checkedFileTypes=docs~functional-code~test-code~other) + + +- **Documentation** + - [User Guide](https://ay2324s2-cs2113-t13-4.github.io/tp/UserGuide.html) + - Added documentation for update, report and expenditure command + - [Developer Guide:](https://ay2324s2-cs2113-t13-4.github.io/tp/DeveloperGuide.html) + - Added implementation details of update command + - Used PlantUML to create the UML class and sequence diagrams for update command + +- **Contributions to team-based tasks:** + - Teammate PR reviewed: [40](https://github.com/AY2324S2-CS2113-T13-4/tp/pull/85), [71](https://github.com/AY2324S2-CS2113-T13-4/tp/pull/71), [85](https://github.com/AY2324S2-CS2113-T13-4/tp/pull/85) + - Contributed to the JUnit tests for update and report + - Helped suggest improvements \ No newline at end of file From 1e5444079c65ff6f5edf4acd41b0b800f3d5470d Mon Sep 17 00:00:00 2001 From: DavidTay Date: Wed, 10 Apr 2024 10:52:57 +0800 Subject: [PATCH 2/2] add more differentiated ways of handling error for revenue and expenditure --- src/main/java/supertracker/parser/Parser.java | 79 +++++++++++-------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/src/main/java/supertracker/parser/Parser.java b/src/main/java/supertracker/parser/Parser.java index 01a9571fd4..31589561fe 100644 --- a/src/main/java/supertracker/parser/Parser.java +++ b/src/main/java/supertracker/parser/Parser.java @@ -496,24 +496,16 @@ private static void validateRevExpFormat( ) throws TrackerException { switch (taskType) { case TODAY: - if (hasStart || hasEnd) { - validateTodayFormat(command); - } + todayErrorFormat(hasStart, hasEnd, command); break; case TOTAL: - if (hasStart || hasEnd) { - validateTotalFormat(command); - } + totalErrorFormat(hasStart, hasEnd, command); break; case DAY: - if (!hasStart || hasEnd || !hasStartParam) { - validateDayFormat(command); - } + dayErrorFormat(hasStart, hasEnd, command, hasStartParam); break; case RANGE: - if (!hasStart || !hasEnd || !hasStartParam || !hasEndParam) { - validateRangeFormat(command); - } + rangeErrorFormat(hasStart, hasEnd, command, hasStartParam, hasEndParam); break; default: handleInvalidFormat(command); @@ -523,35 +515,58 @@ private static void validateRevExpFormat( //@@author //@@author dtaywd - private static void validateTodayFormat(String command) throws TrackerException { - if (command.equals(EXPENDITURE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_EXP_TODAY_FORMAT); - } else if (command.equals(REVENUE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_REV_TODAY_FORMAT); + private static void todayErrorFormat(boolean hasStart, boolean hasEnd, String command) throws TrackerException { + if (hasStart || hasEnd) { + if (command.equals(EXPENDITURE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_EXP_TODAY_FORMAT); + } else if (command.equals(REVENUE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_REV_TODAY_FORMAT); + } } } - private static void validateTotalFormat(String command) throws TrackerException { - if (command.equals(EXPENDITURE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_EXP_TOTAL_FORMAT); - } else if (command.equals(REVENUE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_REV_TOTAL_FORMAT); + private static void totalErrorFormat(boolean hasStart, boolean hasEnd, String command) throws TrackerException { + if (hasStart || hasEnd) { + if (command.equals(EXPENDITURE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_EXP_TOTAL_FORMAT); + } else if (command.equals(REVENUE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_REV_TOTAL_FORMAT); + } } } - private static void validateDayFormat(String command) throws TrackerException { - if (command.equals(EXPENDITURE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_EXP_DAY_FORMAT); - } else if (command.equals(REVENUE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_REV_DAY_FORMAT); + private static void dayErrorFormat( + boolean hasStart, + boolean hasEnd, + String command, + boolean hasStartParam) + throws TrackerException { + if (!hasStart || hasEnd) { + if (command.equals(EXPENDITURE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_EXP_DAY_FORMAT); + } else if (command.equals(REVENUE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_REV_DAY_FORMAT); + } + } else if (!hasStartParam) { + throw new TrackerException(ErrorMessage.EMPTY_PARAM_INPUT); } } - private static void validateRangeFormat(String command) throws TrackerException { - if (command.equals(EXPENDITURE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_EXP_RANGE_FORMAT); - } else if (command.equals(REVENUE_COMMAND)) { - throw new TrackerException(ErrorMessage.INVALID_REV_RANGE_FORMAT); + private static void rangeErrorFormat( + boolean hasStart, + boolean hasEnd, + String command, + boolean hasStartParam, + boolean hasEndParam) + throws TrackerException { + if (!hasStart || !hasEnd) { + if (command.equals(EXPENDITURE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_EXP_RANGE_FORMAT); + } else if (command.equals(REVENUE_COMMAND)) { + throw new TrackerException(ErrorMessage.INVALID_REV_RANGE_FORMAT); + } + } else if (!hasStartParam || !hasEndParam) { + throw new TrackerException(ErrorMessage.EMPTY_PARAM_INPUT); } }