diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 4ae21b442a..39c0cdc4e7 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -28,21 +28,25 @@ Type `help` to see a list of commands that you will be able to use in the applic ## Features -* [Viewing help guide : `help`](#viewing-help-guide-help) -* [Editing your profile : `editprofile`](#editing-your-profile-editprofile) -* [Viewing your profile : `viewprofile`](#viewing-your-profile-viewprofile) -* [Checking your current bmi : `bmi`](#checking-your-current-bmi-bmi) +* [Viewing help guide: `help`](#viewing-help-guide-help) +* [Editing your profile: `editprofile`](#editing-your-profile-editprofile) +* [Viewing your profile: `viewprofile`](#viewing-your-profile-viewprofile) +* [Checking your current bmi: `bmi`](#checking-your-current-bmi-bmi) * [Checking your recommended weight: `checkrecommendedweight`](#checking-your-recommended-weight-checkrecommendedweight) -* [Adding a Meal : `addmeal`](#adding-a-meal-addmeal) -* [Deleting a Meal : `deletemeal`](#deleting-a-meal-deletemeal) -* [Viewing list of all meals : `viewmeal`](#viewing-list-of-all-meals-viewmeal) -* [Finding meals by a keyword : `findmeal`](#finding-meals-by-a-keyword-findmeal) +* [Adding a meal: `addmeal`](#adding-a-meal-addmeal) +* [Deleting a meal: `deletemeal`](#deleting-a-meal-deletemeal) +* [Viewing list of all meals: `viewmeal`](#viewing-list-of-all-meals-viewmeal) +* [Finding meals by a keyword: `findmeal`](#finding-meals-by-a-keyword-findmeal) * [Checking total calories consumed on a specific date: `caloriesconsumed`](#checking-total-calories-consumed-on-a-specific-date-caloriesconsumed) -* [Adding a workout : `addworkout`](#adding-a-workout-addworkout) -* [Deleting a Workout : `deleteworkout`](#deleting-a-workout-deleteworkout) -* [Viewing list of workout : `viewworkout`](#viewing-list-of-all-workouts-viewworkout) -* [Find workouts by a keyword: `findworkout`](#finding-workouts-by-a-keyword-findworkout) +* [Adding a workout: `addworkout`](#adding-a-workout-addworkout) +* [Deleting a workout: `deleteworkout`](#deleting-a-workout-deleteworkout) +* [Viewing list of workout: `viewworkout`](#viewing-list-of-all-workouts-viewworkout) +* [Finding workouts by a keyword: `findworkout`](#finding-workouts-by-a-keyword-findworkout) * [Checking total calories burnt on a specific date: `caloriesburnt`](#checking-total-calories-burnt-on-a-specific-date-caloriesburnt) +* [Adding steps: `addsteps`](#Adding-steps-addsteps) +* [Deleting a step entry: `deletesteps`](#Deleting-a-step-entry-deletesteps) +* [Viewing the total number of steps on a specific date: `totalsteps`](#Viewing-the-total-number-of-steps-on-a-specific-date-totalsteps) +* [Viewing list of all steps: `viewsteps`](#Viewing-list-of-all-steps-viewsteps) * [Exiting the application : `exit`](#exiting-the-application-exit) ### First Time Users @@ -340,11 +344,33 @@ These workouts contain the keyword run: 2. [W] slow run (20kcal, 2023-10-29) ``` + +### Checking total calories burnt on a specific date: `caloriesburnt` +Allows user to check total calories burnt by workouts on a specific date. + +**Format** +- `caloriesburnt ` +- You should type `` in format of `yyyy-MM-dd`. + +**Example of usage** +``` +caloriesburnt 2023-11-04 +``` + +**Expected output** +``` +[W] running (100kcal, 2023-11-04) +[W] swimming (200kcal, 2023-11-04) +[W] walking (30kcal, 2023-11-04) +Total calories burnt on 2023-11-04: 230kcal +``` + + ### Adding steps: `addsteps` Allows user to add their steps walked for a particular day. **Format** -- `addsteps d/` +- `addsteps d/` - You should type `` in format of `yyyy-MM-dd`. **Example of usage** @@ -357,20 +383,8 @@ addsteps 2000 d/2023-10-23 I've added the following steps: [S] 2000 steps (2023-10-23) ``` -### Viewing list of all steps: `viewsteps` -Lists all the steps entries made. -**Example of usage:** -``` -viewsteps -``` -**Expected output:** -``` -These are the steps you have done: -1.[S] 100 steps (2023-10-02) -2.[S] 100 steps (2023-10-02) -``` ### Deleting a step entry: `deletesteps` Allows user to delete a step entry they have added. @@ -389,26 +403,40 @@ I've deleted the following step entry: ``` -### Checking total calories burnt on a specific date: `caloriesburnt` -Allows user to check total calories burnt by workouts on a specific date. +### Viewing the total number of steps on a specific date: `totalsteps` +Calculates the total number of steps on a specific date and shows to user. **Format** -- `caloriesburnt ` +- `totalsteps ` - You should type `` in format of `yyyy-MM-dd`. -**Example of usage** +**Example of usage:** ``` -caloriesburnt 2023-11-04 +totalsteps 2023-10-02 ``` -**Expected output** +**Expected output:** ``` -[W] running (100kcal, 2023-11-04) -[W] swimming (200kcal, 2023-11-04) -[W] walking (30kcal, 2023-11-04) -Total calories burnt on 2023-11-04: 230kcal +Total steps taken: 200 steps ``` + +### Viewing list of all steps: `viewsteps` +Lists all the steps entries made. + +**Example of usage:** +``` +viewsteps +``` + +**Expected output:** +``` +These are the steps you have done: +1.[S] 100 steps (2023-10-02) +2.[S] 100 steps (2023-10-02) +``` + + ### Exiting the application: `exit` Exits the application. @@ -457,26 +485,26 @@ The contents of workoutList.txt: ## Command Summary -| Features | Commands | -|:----------------------------------------------------|:-------------------------| -| Viewing help guide | `help` | -| Exiting the application | `exit` | -| Editing your profile | `editprofile` | -| Viewing your profile | `viewprofile` | -| Checking your current bmi | `bmi` | -| Checking your recommended weight | `checkrecommendedweight` | -| Adding a Meal | `addmeal` | -| Deleting a Meal | `deletemeal` | -| Viewing list of all meals | `viewmeal` | -| Finding meals by a keyword | `findmeal` | -| Checking total calories consumed on a specific date | `caloriesconsumed` | -| Adding a workout | `addworkout` | -| Deleting a Workout | `deleteworkout` | -| Viewing list of workout | `viewworkout` | -| Find workouts by a keyword | `findworkout` | -| Checking total calories burnt on a specific date | `caloriesburnt` | -| Adding a step entry | `addsteps` | -| Deleting a step entry | `deletesteps` | -| Viewing the list of steps | `viewsteps` | -| Calculating the total steps | `totalsteps` | +| Features | Commands | +|:-----------------------------------------------------|:-------------------------| +| Viewing help guide | `help` | +| Exiting the application | `exit` | +| Editing your profile | `editprofile` | +| Viewing your profile | `viewprofile` | +| Checking your current bmi | `bmi` | +| Checking your recommended weight | `checkrecommendedweight` | +| Adding a Meal | `addmeal` | +| Deleting a Meal | `deletemeal` | +| Viewing list of all meals | `viewmeal` | +| Finding meals by a keyword | `findmeal` | +| Checking total calories consumed on a specific date | `caloriesconsumed` | +| Adding a workout | `addworkout` | +| Deleting a Workout | `deleteworkout` | +| Viewing list of workout | `viewworkout` | +| Find workouts by a keyword | `findworkout` | +| Checking total calories burnt on a specific date | `caloriesburnt` | +| Adding a step entry | `addsteps` | +| Deleting a step entry | `deletesteps` | +| Viewing the total number of steps on a specific date | `totalsteps` | +| Viewing the list of steps | `viewsteps` | diff --git a/src/main/java/fittrack/FitTrack.java b/src/main/java/fittrack/FitTrack.java index a85b5667d8..c1f4e85a7e 100644 --- a/src/main/java/fittrack/FitTrack.java +++ b/src/main/java/fittrack/FitTrack.java @@ -4,6 +4,7 @@ import fittrack.command.CommandResult; import fittrack.command.ExitCommand; import fittrack.parser.CommandParser; +import fittrack.parser.ParseException; import fittrack.storage.Storage; import fittrack.storage.Storage.StorageOperationException; import fittrack.storage.Storage.InvalidStorageFilePathException; @@ -22,37 +23,34 @@ public class FitTrack { public static final String VERSION = "FitTrack - Version 2.1"; private final Ui ui; - private Storage storage; + private final Storage storage; private UserProfile userProfile; private MealList mealList; private WorkoutList workoutList; private StepList stepList; - private FitTrack() { - ui = new Ui(); - userProfile = new UserProfile(); - mealList = new MealList(); - workoutList = new WorkoutList(); + private FitTrack(String[] storagePaths) { + this.ui = new Ui(); + this.storage = initializeStorage(storagePaths); } /** * Main entry-point for the FitTrack application. */ public static void main(String[] args) { - new FitTrack().run(args); + new FitTrack(args).run(); } - private void run(String[] args) { - start(args); + private void run() { + start(); loopCommandExecution(); end(); } - private void start(String[] args) { + private void start() { ui.printVersion(); ui.printWelcome(); - boolean isProfileLoaded = loadStorage(args); - userProfile.startProfile(userProfile, ui, storage, isProfileLoaded); + load(); } private void loopCommandExecution() { @@ -60,55 +58,102 @@ private void loopCommandExecution() { do { String userCommandLine = ui.scanCommandLine(); command = CommandParser.parseCommand(userCommandLine); + CommandResult commandResult = executeCommand(command); + ui.printCommandResult(commandResult); ui.printLine(); } while (!ExitCommand.isExit(command)); } private CommandResult executeCommand(Command command) { - try { - command.setData(userProfile, mealList, workoutList, stepList, storage); - CommandResult result = command.execute(); - storage.save(userProfile, mealList, workoutList, stepList); - return result; - } catch (IOException e) { - System.out.println(e.getMessage()); - throw new RuntimeException(); - } + command.setData(userProfile, mealList, workoutList, stepList); + CommandResult result = command.execute(); + save(); + return result; } - private boolean loadStorage(String[] args) { - boolean isFirstTime = false; + private void end() { + save(); + } + + // @@author J0shuaLeong + private void load() { + // TODO: This method will be eventually changed due to Joshua's Storage rework. try { - this.storage = initializeStorage(args); if (!storage.isProfileFileEmpty()) { this.userProfile = storage.profileLoad(); ui.printPrompt(); - isFirstTime = true; } this.mealList = storage.mealLoad(); this.workoutList = storage.workoutLoad(); this.stepList = storage.stepLoad(); - return isFirstTime; - } catch (StorageOperationException | InvalidStorageFilePathException e) { + } catch (StorageOperationException e) { + // TODO: Use Ui. System.out.println("There was a problem with the loading of storage contents."); ui.printLine(); } - return isFirstTime; + + if (userProfile == null) { + initUserProfile(); + } + if (mealList == null) { + mealList = new MealList(); + } + if (workoutList == null) { + workoutList = new WorkoutList(); + } + if (stepList == null) { + stepList = new StepList(); + } + save(); + } + // @@author + + // @@author J0shuaLeong + public void initUserProfile() { + boolean isInputValid = false; + while (!isInputValid) { + try { + String input = ui.scanUserProfile(); + userProfile = UserProfile.parseUserProfile(input); + ui.printProfileDetails(userProfile); + isInputValid = true; + } catch (ParseException e) { + ui.printException(e); + } + } } + // @@author /** * Creates the StorageFile object based on the user specified path (if any) or the default storage path. * * @param args arguments supplied by the user at program launch - * @throws InvalidStorageFilePathException if the target file path is incorrect. */ - private Storage initializeStorage(String[] args) throws InvalidStorageFilePathException { - boolean isStorageFileSpecifiedByUser = args.length > 0; - return isStorageFileSpecifiedByUser ? new Storage(args[0], args[1], args[2], args[3]) : new Storage(); + // @@author J0shuaLeong + private Storage initializeStorage(String[] args) { + if (args.length == 4) { + try { + return new Storage(args[0], args[1], args[2], args[3]); + } catch (InvalidStorageFilePathException e) { + ui.printStoragePathSettingFailure(); + return new Storage(); + } + } else if (args.length == 0) { + return new Storage(); + } else { + ui.printStoragePathSettingFailure(); + return new Storage(); + } } + // @@author J0shuaLeong - private void end() { + private void save() { + try { + storage.save(userProfile, mealList, workoutList, stepList); + } catch (IOException e) { + ui.printSaveFailure(); + } } } diff --git a/src/main/java/fittrack/Ui.java b/src/main/java/fittrack/Ui.java index 744c4ba23d..db3da2502c 100644 --- a/src/main/java/fittrack/Ui.java +++ b/src/main/java/fittrack/Ui.java @@ -8,14 +8,11 @@ * Represents the user interface of FitTrack. */ public class Ui { - private static final String LOGO = "___________.__ __ ___________ __\n" + "\\_ _____/|__|/ |\\__ ___/___________ ____ | | __\n" + " | __) | \\ __\\| | \\_ __ \\__ \\ _/ ___\\| |/ /\n" + " | \\ | || | | | | | \\/ __ \\ \\___| <\n" + " \\___ / |__||__| |____| |__| (____ /\\___ >__|_ \\"; - - private static final String LINE = "____________________________________________________________"; private final Scanner in; @@ -45,6 +42,17 @@ public String scanCommandLine() { return scanNextLine(); } + // @@author J0shuaLeong + public String scanUserProfile() { + System.out.println( + "Please enter your height (in cm), weight (in kg), " + + "gender (M or F), and daily calorie limit (in kcal).\n" + + "Enter in format of `h/ w/ g/ l/`." + ); + return scanNextLine(); + } + // @@author + public void printBlankLine() { System.out.println(); } @@ -73,13 +81,6 @@ public void printPrompt() { printLine(); } - public String profileMessageAndScanner() { - System.out.println( - "Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal):" - ); - return scanNextLine(); - } - /** * Prints the profile details of the user after user has * entered details for the first time. @@ -91,4 +92,16 @@ public void printProfileDetails(UserProfile profile) { System.out.println("Height: " + profile.toString()); printLine(); } + + public void printStoragePathSettingFailure() { + System.out.println("One of given storage paths is invalid. Proceeding with default paths."); + } + + public void printSaveFailure() { + System.out.println("Failed to save data."); + } + + public void printException(Exception e) { + System.out.println(e.getMessage()); + } } diff --git a/src/main/java/fittrack/UserProfile.java b/src/main/java/fittrack/UserProfile.java index 5b7a717dee..97b12ea97f 100644 --- a/src/main/java/fittrack/UserProfile.java +++ b/src/main/java/fittrack/UserProfile.java @@ -5,12 +5,9 @@ import fittrack.data.Height; import fittrack.data.Calories; import fittrack.data.Bmi; -import fittrack.parser.NumberFormatException; import fittrack.parser.ParseException; import fittrack.parser.PatternMatchFailException; -import fittrack.storage.Storage; -import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -115,39 +112,4 @@ public static UserProfile parseUserProfile(String s) throws ParseException { Gender gender = Gender.parseGender(genderData); return new UserProfile(height, weight, dailyCalorieLimit, gender); } - - /** - * Gets user profile details when program starts. - * - * @throws PatternMatchFailException if regex match fails - * @throws NumberFormatException if one of arguments is not double - */ - public void profileSettings(String input) throws ParseException { - assert (input != null) : "Profile cannot be null"; - - UserProfile profile = parseUserProfile(input); - setHeight(profile.getHeight()); - setWeight(profile.getWeight()); - setDailyCalorieLimit(profile.getDailyCalorieLimit()); - setGender(profile.getGender()); - } - - public void startProfile(UserProfile userProfile, Ui ui, Storage storage, boolean isProfileLoaded) { - while (!isProfileLoaded) { - try { - String input = ui.profileMessageAndScanner(); - profileSettings(input); - ui.printProfileDetails(userProfile); - storage.saveProfile(userProfile); - isProfileLoaded = true; - } catch (PatternMatchFailException e) { - System.out.println("Wrong format. Please enter h/ w/ g/ l/"); - } catch (IOException e) { - System.out.println("Error occurred while saving profile."); - isProfileLoaded = true; - } catch (ParseException e) { - System.out.println(e.getMessage()); - } - } - } } diff --git a/src/main/java/fittrack/command/AddStepsCommand.java b/src/main/java/fittrack/command/AddStepsCommand.java index 5c61407f84..d9a2d6e020 100644 --- a/src/main/java/fittrack/command/AddStepsCommand.java +++ b/src/main/java/fittrack/command/AddStepsCommand.java @@ -3,12 +3,12 @@ import fittrack.data.Step; import fittrack.parser.ParseException; -public class AddStepsCommand extends Command{ +public class AddStepsCommand extends Command { public static final String COMMAND_WORD = "addsteps"; private static final String DESCRIPTION = - String.format("`%s` shows your total number of steps on a specific date.", COMMAND_WORD); + String.format("`%s` adds your step data to the list.", COMMAND_WORD); private static final String USAGE = String.format( - "Type `%s ` to add an entry of the steps walked on that date.\n" + + "Type `%s d/` to add an entry of the steps walked on that date.\n" + "You should type in format of `yyyy-MM-dd`.", COMMAND_WORD ); @@ -42,9 +42,6 @@ public void setArguments(String args) throws ParseException { newStep = Step.parseStep(args); } - public Step getStep(){ - return newStep; - } /** * Returns help of the command. * diff --git a/src/main/java/fittrack/command/Command.java b/src/main/java/fittrack/command/Command.java index 8af20a8ac6..e05653493f 100644 --- a/src/main/java/fittrack/command/Command.java +++ b/src/main/java/fittrack/command/Command.java @@ -4,7 +4,6 @@ import fittrack.StepList; import fittrack.UserProfile; import fittrack.WorkoutList; -import fittrack.storage.Storage; import fittrack.parser.ParseException; public abstract class Command { @@ -13,7 +12,6 @@ public abstract class Command { protected MealList mealList; protected WorkoutList workoutList; protected StepList stepList; - protected Storage storage; public Command(String commandLine) { this.commandLine = commandLine; @@ -26,13 +24,16 @@ public Command(String commandLine) { * @param mealList meal list * @param workoutList work list */ - public void setData(UserProfile userProfile, MealList mealList, WorkoutList workoutList, - StepList stepList, Storage storage) { + public void setData( + UserProfile userProfile, + MealList mealList, + WorkoutList workoutList, + StepList stepList + ) { this.userProfile = userProfile; this.mealList = mealList; this.workoutList = workoutList; this.stepList = stepList; - this.storage = storage; } /** diff --git a/src/main/java/fittrack/command/ExitCommand.java b/src/main/java/fittrack/command/ExitCommand.java index 12d69a0dae..e80f70b663 100644 --- a/src/main/java/fittrack/command/ExitCommand.java +++ b/src/main/java/fittrack/command/ExitCommand.java @@ -2,9 +2,6 @@ import fittrack.parser.PatternMatchFailException; -import java.io.IOException; - - public class ExitCommand extends Command { public static final String COMMAND_WORD = "exit"; private static final String DESCRIPTION = "`" + COMMAND_WORD + "` halts the app."; @@ -22,11 +19,6 @@ public static boolean isExit(Command command) { @Override public CommandResult execute() { - try { - storage.save(userProfile, mealList, workoutList, stepList); - } catch (IOException e) { - System.out.println("Failed to save to storage."); - } return new CommandResult(MESSAGE_EXIT); } diff --git a/src/main/java/fittrack/command/TotalStepsCommand.java b/src/main/java/fittrack/command/TotalStepsCommand.java index 3a5550e190..cd540fcefd 100644 --- a/src/main/java/fittrack/command/TotalStepsCommand.java +++ b/src/main/java/fittrack/command/TotalStepsCommand.java @@ -4,15 +4,15 @@ import fittrack.data.Step; import fittrack.parser.ParseException; -public class TotalStepsCommand extends Command{ +public class TotalStepsCommand extends Command { public static final String COMMAND_WORD = "totalsteps"; - private static final String DESCRIPTION = "`" + COMMAND_WORD + "` shows the total number of steps taken."; + private static final String DESCRIPTION = + String.format("`%s` shows the total number of steps taken on a specific date.", COMMAND_WORD); private static final String USAGE = "Type `%s` to show the total number of steps walked on that date.\n."+ "You should type in format of `yyyy-MM-dd`."; public static final String HELP = DESCRIPTION + "\n" + USAGE; private Date date; - private Step totalSteps; public TotalStepsCommand(String commandLine) { super(commandLine); @@ -20,13 +20,10 @@ public TotalStepsCommand(String commandLine) { @Override public CommandResult execute() { - StringBuilder feedbackBuilder = new StringBuilder(); - totalSteps = new Step(0, null); - + Step totalSteps = new Step(0, null); for (Step step: stepList.getStepList()) { if (date.equals(step.getDate())) { totalSteps = totalSteps.sum(step); - feedbackBuilder.append(step).append("\n"); } } return new CommandResult("Total steps taken: " + totalSteps.getSteps() + " steps"); diff --git a/src/main/java/fittrack/data/Step.java b/src/main/java/fittrack/data/Step.java index 77a344a552..7cedd2a99f 100644 --- a/src/main/java/fittrack/data/Step.java +++ b/src/main/java/fittrack/data/Step.java @@ -13,11 +13,11 @@ public class Step { private static final String STEP_CG = "step"; private static final String DATE_CG = "date"; private static final Pattern STEP_PATTERN = Pattern.compile( - "(?<" + STEP_CG + ">\\S+)(\\s+d/(?<" + DATE_CG + ">\\S+))?" + "(?<" + STEP_CG + ">\\S+)\\s+d/(?<" + DATE_CG + ">\\S+)" ); private final int steps; - private Date date; + private final Date date; public Step(int steps, Date date) { assert steps >= 0 && date != null; diff --git a/src/main/java/fittrack/unused/SaveCommand.java b/src/main/java/fittrack/unused/SaveCommand.java index ea64135899..2f7763e14e 100644 --- a/src/main/java/fittrack/unused/SaveCommand.java +++ b/src/main/java/fittrack/unused/SaveCommand.java @@ -5,8 +5,6 @@ import fittrack.command.CommandResult; import fittrack.parser.PatternMatchFailException; -import java.io.IOException; - public class SaveCommand extends Command { public static final String COMMAND_WORD = "save"; private static final String DESCRIPTION = @@ -21,11 +19,11 @@ public SaveCommand(String commandLine) { @Override public CommandResult execute() { - try { - storage.save(userProfile, mealList, workoutList, stepList); - } catch (IOException e) { - System.out.println(e.getMessage()); - } + // try { + // storage.save(userProfile, mealList, workoutList, stepList); + // } catch (IOException e) { + // System.out.println(e.getMessage()); + // } return new CommandResult("Your data has been saved!"); } diff --git a/src/test/java/fittrack/command/CaloriesBurntCommandTest.java b/src/test/java/fittrack/command/CaloriesBurntCommandTest.java index a5bfe053ee..d7f6341d5e 100644 --- a/src/test/java/fittrack/command/CaloriesBurntCommandTest.java +++ b/src/test/java/fittrack/command/CaloriesBurntCommandTest.java @@ -27,7 +27,7 @@ public void setUp() { public void testExecute() throws ParseException { CaloriesBurntCommand caloriesBurntCommand = new CaloriesBurntCommand(CaloriesBurntCommand.COMMAND_WORD); caloriesBurntCommand.setArguments("2023-10-23"); - caloriesBurntCommand.setData(null, null, workoutList, null, null); + caloriesBurntCommand.setData(null, null, workoutList, null); CommandResult result = caloriesBurntCommand.execute(); assertEquals("[W] workout1 (100kcal, 2023-10-23)\n" + "[W] workout2 (200kcal, 2023-10-23)\n" + diff --git a/src/test/java/fittrack/command/EditProfileCommandTest.java b/src/test/java/fittrack/command/EditProfileCommandTest.java index b0fee7128a..2193c3cc00 100644 --- a/src/test/java/fittrack/command/EditProfileCommandTest.java +++ b/src/test/java/fittrack/command/EditProfileCommandTest.java @@ -16,7 +16,7 @@ public class EditProfileCommandTest { public void setUp() { editProfileCommand = new EditProfileCommand(EditProfileCommand.COMMAND_WORD); userProfile = new UserProfile(); - editProfileCommand.setData(userProfile, null, null, null, null); + editProfileCommand.setData(userProfile, null, null, null); } @Test diff --git a/src/test/java/fittrack/command/FindMealCommandTest.java b/src/test/java/fittrack/command/FindMealCommandTest.java index b560b033f5..c552173359 100644 --- a/src/test/java/fittrack/command/FindMealCommandTest.java +++ b/src/test/java/fittrack/command/FindMealCommandTest.java @@ -41,7 +41,7 @@ public void execute() throws PatternMatchFailException, NullPointerException { void assertFindCommandBehavior(String commandLine, String keyword) throws PatternMatchFailException { FindMealCommand findCommand = new FindMealCommand(commandLine); findCommand.setArguments(keyword); - findCommand.setData(null, mealList, null, null, null); + findCommand.setData(null, mealList, null, null); CommandResult result = findCommand.execute(); assertEquals(result1, result.getFeedback()); } diff --git a/src/test/java/fittrack/command/FindWorkoutCommandTest.java b/src/test/java/fittrack/command/FindWorkoutCommandTest.java index 22b20b52b8..3f4d5b36b2 100644 --- a/src/test/java/fittrack/command/FindWorkoutCommandTest.java +++ b/src/test/java/fittrack/command/FindWorkoutCommandTest.java @@ -45,7 +45,7 @@ void assertFindCommandBehavior(String commandLine, String keyword, String expect throws PatternMatchFailException { FindWorkoutCommand findCommand = new FindWorkoutCommand(commandLine); findCommand.setArguments(keyword); - findCommand.setData(null, null, workoutList, null, null); + findCommand.setData(null, null, workoutList, null); CommandResult result = findCommand.execute(); assertEquals(expectedResult, result.getFeedback()); } diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index faf89ff70f..c36b9f5ba1 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,3 +1,4 @@ +Directory created: data FitTrack - Version 2.1 Welcome to FitTrack! ___________.__ __ ___________ __ @@ -6,24 +7,32 @@ ___________.__ __ ___________ __ | \ | || | | | | | \/ __ \ \___| < \___ / |__||__| |____| |__| (____ /\___ >__|_ \ ____________________________________________________________ -Directory created: data -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. Weight must be a number. -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. Height must be a positive value. -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. Weight must be a positive value. -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. Calories must not be a negative value. -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): -Wrong format. Please enter h/ w/ g/ l/ -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): -Wrong format. Please enter h/ w/ g/ l/ -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): -Wrong format. Please enter h/ w/ g/ l/ -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): -Wrong format. Please enter h/ w/ g/ l/ -Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal): +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. +The input pattern is not valid. +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. +The input pattern is not valid. +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. +The input pattern is not valid. +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. +The input pattern is not valid. +Please enter your height (in cm), weight (in kg), gender (M or F), and daily calorie limit (in kcal). +Enter in format of `h/ w/ g/ l/`. Here are your profile settings. Height: Height: 180.0cm Weight: 80.0kg @@ -204,14 +213,14 @@ Recommended Weight: 66.02 kg ____________________________________________________________ `addsteps 2000 d/` is an invalid command. The input pattern is not valid. -`addsteps` shows your total number of steps on a specific date. -Type `addsteps ` to add an entry of the steps walked on that date. +`addsteps` adds your step data to the list. +Type `addsteps d/` to add an entry of the steps walked on that date. You should type in format of `yyyy-MM-dd`. ____________________________________________________________ `addsteps` is an invalid command. The input pattern is not valid. -`addsteps` shows your total number of steps on a specific date. -Type `addsteps ` to add an entry of the steps walked on that date. +`addsteps` adds your step data to the list. +Type `addsteps d/` to add an entry of the steps walked on that date. You should type in format of `yyyy-MM-dd`. ____________________________________________________________ @@ -220,20 +229,20 @@ Type `help` or `help ` to view help. ____________________________________________________________ `addsteps 200 d/2023-11` is an invalid command. The date format is not valid. -`addsteps` shows your total number of steps on a specific date. -Type `addsteps ` to add an entry of the steps walked on that date. +`addsteps` adds your step data to the list. +Type `addsteps d/` to add an entry of the steps walked on that date. You should type in format of `yyyy-MM-dd`. ____________________________________________________________ `addsteps 2000 2023-11-11` is an invalid command. The input pattern is not valid. -`addsteps` shows your total number of steps on a specific date. -Type `addsteps ` to add an entry of the steps walked on that date. +`addsteps` adds your step data to the list. +Type `addsteps d/` to add an entry of the steps walked on that date. You should type in format of `yyyy-MM-dd`. ____________________________________________________________ -`addsteps d/2023-11-11` is an invalid command. For input string: "d/2023-11-11" -`addsteps` shows your total number of steps on a specific date. -Type `addsteps ` to add an entry of the steps walked on that date. +`addsteps d/2023-11-11` is an invalid command. The input pattern is not valid. +`addsteps` adds your step data to the list. +Type `addsteps d/` to add an entry of the steps walked on that date. You should type in format of `yyyy-MM-dd`. ____________________________________________________________ @@ -241,9 +250,9 @@ I've added the following steps: [S] 2000 steps (2023-11-11) ____________________________________________________________ -`addsteps d/` is an invalid command. For input string: "d/" -`addsteps` shows your total number of steps on a specific date. -Type `addsteps ` to add an entry of the steps walked on that date. +`addsteps d/` is an invalid command. The input pattern is not valid. +`addsteps` adds your step data to the list. +Type `addsteps d/` to add an entry of the steps walked on that date. You should type in format of `yyyy-MM-dd`. ____________________________________________________________