Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #103

Merged
merged 30 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
37dddc1
Fixed code review suggestions
kevinz420 Nov 10, 2023
b38e21c
Added various bug fixes
kevinz420 Nov 10, 2023
6f85446
Merge branch 'master' into bug-fixes
kevinz420 Nov 10, 2023
0481643
Fix merge conflicts
Remy9926 Nov 14, 2023
eced366
Fix bugs
Remy9926 Nov 14, 2023
d6ab466
Fix bugs
Remy9926 Nov 14, 2023
749e167
Working v2.1
Remy9926 Nov 14, 2023
26ece1b
Add exit command handling
Remy9926 Nov 14, 2023
e0e266b
Fix checkstyle
Remy9926 Nov 14, 2023
d062697
Fix checkstyle
Remy9926 Nov 14, 2023
b00a41f
Update to current version
Remy9926 Nov 14, 2023
1eaa734
Fix checkstyle
Remy9926 Nov 14, 2023
07fa3e5
Fix checktyle
Remy9926 Nov 14, 2023
9d786f8
Fix checkstyle
Remy9926 Nov 14, 2023
7c57ecf
Merge branch 'master' into bug-fixes
Remy9926 Nov 14, 2023
e3cbc3a
Fix checkstyle
Remy9926 Nov 14, 2023
0fecda0
Merge branch 'bug-fixes' of https://github.com/Remy9926/tp into bug-f…
Remy9926 Nov 14, 2023
cd4b820
Fix checkstyle
Remy9926 Nov 14, 2023
71b8303
Fix checkstyle
Remy9926 Nov 14, 2023
4fc3629
Fix checkstyle
Remy9926 Nov 14, 2023
3ac492a
Fix checkstyle
Remy9926 Nov 14, 2023
b75fe10
Fix checkstyle
Remy9926 Nov 14, 2023
dad921d
Fix checkstyle
Remy9926 Nov 14, 2023
b4b3451
Fix checkstyle
Remy9926 Nov 14, 2023
ba07037
Fix checkstyle
Remy9926 Nov 14, 2023
3ad255f
Fix checkstyle
Remy9926 Nov 14, 2023
562fff5
Fix checkstyle
Remy9926 Nov 14, 2023
562ad59
Merge branch 'master' into bug-fixes
Remy9926 Nov 14, 2023
c705f89
Fix checkstyle
Remy9926 Nov 14, 2023
f147af2
Fix checkstyle
Remy9926 Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ src/main/resources/docs/
*.iml
bin/

/text-ui-test/ACTUAL.TXT
/text-ui-test/EXPECTED.TXT
text-ui-test/EXPECTED-UNIX.TXT

data
4 changes: 0 additions & 4 deletions src/main/java/seedu/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ private void start(String[] launchArgs) {
ui = new TextUi();
exerciseLogStorage = ExerciseLogStorage.initializeStorage(dirPath, exerciseLogFilePath);
exerciseLogStorage.checkForLogTextFile(exerciseLog);
goalStorage = GoalStorage.initializeGoalStorage(dirPath, goalFilePath);
goalStorage.restoreGoalRecord();
achmStorage = AchmStorage.initializeGoalStorage(dirPath, achmFilePath);
achmStorage.restoreGoalRecord();
ui.showWelcomeMessage(VERSION, "storage.getPath()");
} catch (Exception e) { // TODO: change to specific storage exceptions later
ui.showInitFailedMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public CommandResult execute() {
} catch (Exception e) {
feedbackToUser = "Something went wrong, please try again.";
}

return new CommandResult(feedbackToUser);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ public CommandResult execute() {

return new CommandResult(feedbackToUser);
}


}
2 changes: 0 additions & 2 deletions src/main/java/seedu/duke/commands/goal/DeleteGoalCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@ public CommandResult execute() {

return new CommandResult(feedbackToUser);
}


}
4 changes: 0 additions & 4 deletions src/main/java/seedu/duke/commands/goal/GoalCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public CommandResult execute() {
feedbackToUser = "Something went wrong, please try again.";
}




return new CommandResult(feedbackToUser);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ public CommandResult execute() {

return new CommandResult(feedbackToUser);
}

}
12 changes: 5 additions & 7 deletions src/main/java/seedu/duke/data/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import java.time.format.DateTimeFormatter;
import java.util.Locale;

// import com.google.gson.annotations.SerializedName;

/**
* Customized class for showing date and parsing supported string to date.
*/
Expand All @@ -29,22 +27,22 @@ public class Date {
* @param NotAllowPast true for all goal related commands only
* @throws IncorrectFormatException if failed to parse date string input
*/
public Date(String rawData, Boolean NotAllowPast) throws IncorrectFormatException {
setRawData(rawData, NotAllowPast);
public Date(String rawData, Boolean notAllowPast) throws IncorrectFormatException {
setRawData(rawData, notAllowPast);
}

/**
* The method is used to set up the date field of a Date object
* It contains the actual implementation to parse date information from a string
* @param rawData refers to a date string
* @param NotAllowPast if past is not allowed, for example for goal functions
* @param notAllowPast if past is not allowed, for example for goal functions
* @throws IncorrectFormatException if failed to parse date string input
*/
public void setRawData(String rawData, boolean NotAllowPast) throws IncorrectFormatException {
public void setRawData(String rawData, boolean notAllowPast) throws IncorrectFormatException {
for (DateTimeFormatter formatter : formatters) {
try {
date = LocalDate.parse(rawData, formatter);
if (NotAllowPast) {
if (notAllowPast) {
if (date.isBefore(LocalDate.now())) {
throw new IncorrectFormatException("Target Deadline has passed! ");
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/seedu/duke/goal/GoalList.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public int getGoalCount() {
/**
* This method removes a goal object from the global field goals list by indexing
* It also decrements goalCount by 1
* @param cmd Raw user Command
* @param cmd Raw user command
* @return message of succeeding to delete goal and tell user the updated total number of goals
* @throws IOException if failed to access output file
* @throws NumberFormatException if index is invalid number
* @throws IncorrectFormatException is user command is in incorrect format
* @return message of succeeding to delete goal and tell user the updated total number of goals
*/
public static String deleteGoal(String cmd) throws IncorrectFormatException,
NumberFormatException, IOException {
Expand Down Expand Up @@ -145,10 +145,10 @@ private static void verifyAchieveGoalInput(String cmd) throws IncorrectFormatExc
* @param userCmd represents raw user input
* @param target represents to target list to add new goal
* @param storage represents the target storage to update goal data
* @return String about succeeding to create goal object
* @throws IncorrectFormatException if user input is in wrong format
* @throws NumberFormatException if the user does not input a valid number
* @throws IOException if failed to access and update output file
* @return String about succeeding to create goal object
*/
public static String addGoal(String userCmd, GoalList target, GoalStorage storage) throws IncorrectFormatException,
NumberFormatException, IOException {
Expand Down Expand Up @@ -207,5 +207,4 @@ public String toString() {
return "Consume " + this.calories + " kcal on " + this.date;
}
}

}
7 changes: 5 additions & 2 deletions src/main/java/seedu/duke/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
import java.util.regex.Pattern;

import seedu.duke.commands.Command;
import seedu.duke.commands.goal.*;
import seedu.duke.commands.HelpCommand;
import seedu.duke.commands.goal.GoalCommand;
import seedu.duke.commands.goal.DeleteGoalCommand;
import seedu.duke.commands.goal.ViewGoalCommand;
import seedu.duke.commands.goal.AchievementCommand;
import seedu.duke.commands.goal.AchieveGoalCommand;
import seedu.duke.commands.IncorrectCommand;
import seedu.duke.commands.logcommands.LogCommand;
import seedu.duke.commands.logcommands.DeleteLogCommand;
Expand Down Expand Up @@ -136,5 +140,4 @@ public static class ParseException extends Exception {
super(message);
}
}

}
4 changes: 0 additions & 4 deletions src/main/java/seedu/duke/storagefile/AchmStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,4 @@ protected void textToGoalObject(String goalRecord) throws Exception {
String restoredCommand = restoreOrigionalCommand(goalRecord);
GoalList.addGoal(restoredCommand, Duke.achievedGoals, Duke.achmStorage);
}



}

1 change: 0 additions & 1 deletion src/main/java/seedu/duke/storagefile/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

class Storage {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/duke/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import java.util.Optional;
import java.util.Scanner;

import seedu.duke.Duke;
import seedu.duke.commands.CommandResult;
import seedu.duke.goal.GoalList;
import seedu.duke.data.Printable;
import seedu.duke.Duke;

/**
* Text UI of the application.
Expand Down
33 changes: 18 additions & 15 deletions src/test/java/seedu/duke/parser/ParserTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.duke.parser;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.duke.common.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import org.junit.jupiter.api.BeforeEach;
Expand All @@ -26,15 +27,8 @@ public void parse_emptyInput_returnsIncorrect() throws Exception {
parseAndAssertIncorrectWithMessage(resultMessage, emptyInputs);
}

@Test
public void parse_unknownCommandWord_returnsHelp() throws Exception {
final String input = "unknowncommandword arguments arguments";
parseAndAssertCommandType(input, HelpCommand.class);
}

/*
* Tests for 0-argument commands
* =======================================================================
* Tests for 0-argument commands =======================================================================
*/

@Test
Expand All @@ -50,21 +44,30 @@ public void parse_exitCommand_parsedCorrectly() throws Exception {
}

/*
* Utility methods
* =============================================================================
* =======
* Utility methods ====================================================================================
*/

/**
* Asserts that parsing the given inputs will return IncorrectCommand with the
* given feedback message.
*
* @throws Exception
* Asserts that parsing the given inputs will return IncorrectCommand with the given feedback message.
*/
private void parseAndAssertIncorrectWithMessage(String feedbackMessage, String... inputs) throws Exception {
for (String input : inputs) {
final IncorrectCommand result = parseAndAssertCommandType(input, IncorrectCommand.class);
assertEquals(result.feedbackToUser, feedbackMessage);
}
}

/**
* Parses input and asserts the class/type of the returned command object.
*
* @param input to be parsed
* @param expectedCommandClass expected class of returned command
* @return the parsed command object
*/
private <T extends Command> T parseAndAssertCommandType(String input, Class<T> expectedCommandClass)
throws Exception {
final Command result = parser.parseCommand(input);
assertTrue(result.getClass().isAssignableFrom(expectedCommandClass));
return (T) result;
}
}
13 changes: 0 additions & 13 deletions text-ui-test/EXPECTED.TXT

This file was deleted.

Loading