Skip to content

Commit

Permalink
Move Goal class into goal package
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Y-Yan committed Nov 14, 2023
1 parent 7e6e5c8 commit 647881b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
21 changes: 0 additions & 21 deletions src/main/java/seedu/duke/data/Goal.java

This file was deleted.

19 changes: 18 additions & 1 deletion src/main/java/seedu/duke/goal/GoalList.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.io.IOException;
import java.util.ArrayList;

public class GoalList extends ArrayList<Goal> {
public class GoalList extends ArrayList<GoalList.Goal> {
private static final String DATEKEYWORD = "on";

private ArrayList<Goal> goals;
Expand Down Expand Up @@ -184,5 +184,22 @@ public static void verifyViewAchievementInput(String cmd) throws IncorrectFormat
}
}

public static class Goal {
private int calories;
private Date date;

public Goal(int calories, String date) throws IncorrectFormatException {
this.calories = calories;
this.date = setGoalDateTime(date);
}

private Date setGoalDateTime(String date) throws IncorrectFormatException {
return new Date(date);
}

public String toString() {
return "Consume " + this.calories + " kcal on " + this.date;
}
}
}

5 changes: 2 additions & 3 deletions src/main/java/seedu/duke/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

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

Expand Down Expand Up @@ -203,7 +202,7 @@ public static String noOfGoalMsg(int goalCount) {
return "You now have " + goalCount + " goals to accomplish.";
}

public static String deleteGoalMsg(Goal deletedGoal) {
public static String deleteGoalMsg(GoalList.Goal deletedGoal) {

return "Good. I have removed this goal: " + deletedGoal + "\n"
+ "Remember not to give up unaccomplished target!" + "\n";
Expand All @@ -216,7 +215,7 @@ public static String deleteGoalMsg(Goal deletedGoal) {
*/
public static String addGoalSuccessMessage() {
int currentNoOfGoal = Duke.goalList.getGoalCount();
Goal newlyAddedGoal = Duke.goalList.getGoal(currentNoOfGoal - 1);
GoalList.Goal newlyAddedGoal = Duke.goalList.getGoal(currentNoOfGoal - 1);
return "Nice! I have added the following goal to your goals list: \n\t" + newlyAddedGoal;
}

Expand Down

0 comments on commit 647881b

Please sign in to comment.