Skip to content

Commit

Permalink
Merge pull request #27 from MrOPPA1/master
Browse files Browse the repository at this point in the history
fix meal
  • Loading branch information
MrOPPA1 authored Oct 27, 2023
2 parents a0bdfd1 + c3c2e90 commit 9a4efd0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 44 deletions.
6 changes: 5 additions & 1 deletion src/main/java/seedu/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import seedu.duke.commands.Command;
import seedu.duke.commands.CommandResult;
import seedu.duke.commands.ExitCommand;
import seedu.duke.commands.meal.MealCommand;
import seedu.duke.data.GoalList;
import seedu.duke.data.meal.Meal;
import seedu.duke.parser.Parser;
import seedu.duke.exerciselog.Log;
import seedu.duke.ui.TextUi;
import java.util.ArrayList;

/**
* Entry point of the Address Book application.
Expand All @@ -21,6 +24,7 @@ public class Duke {
public static GoalList goals = new GoalList();
public static Log exerciseLog = new Log();
private TextUi ui;
static ArrayList<Meal> meals = new ArrayList<Meal>();

// private StorageFile storage;
public static void main(String... launchArgs) {
Expand Down Expand Up @@ -48,7 +52,7 @@ private void start(String[] launchArgs) {
this.ui = new TextUi();
// this.storage = initializeStorage(launchArgs);
ui.showWelcomeMessage(VERSION, "storage.getPath()");

MealCommand.setMeals(meals);
} catch (Exception e) { // TODO: change to specific storage exceptions later
ui.showInitFailedMessage();
throw new RuntimeException(e);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/duke/data/meal/Meal.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
public class Meal {
public String name;
public int calories;
public DateTime time;
// public DateTime time;

public Meal(String name, int calories) throws Exception {
this.name = name;
this.calories = calories;
this.time = new DateTime(LocalDateTime.now().toString());
// this.time = new DateTime(LocalDateTime.now().toString());
}
}
86 changes: 45 additions & 41 deletions src/main/java/seedu/duke/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import seedu.duke.commands.logcommands.LogCommand;
import seedu.duke.commands.logcommands.DeleteLogCommand;
import seedu.duke.commands.logcommands.ViewLogCommand;
import seedu.duke.commands.meal.MealCommand;
import seedu.duke.data.exception.IllegalValueException;

/**
Expand Down Expand Up @@ -52,47 +53,50 @@ public Command parseCommand(String userInput) {

switch (commandWord) {

// case AddCommand.COMMAND_WORD:
// return prepareAdd(arguments);
//
// case DeleteCommand.COMMAND_WORD:
// return prepareDelete(arguments);
//
// case ClearCommand.COMMAND_WORD:
// return new ClearCommand();
//
// case FindCommand.COMMAND_WORD:
// return prepareFind(arguments);
//
// case ListCommand.COMMAND_WORD:
// return new ListCommand();
//
// case ViewCommand.COMMAND_WORD:
// return prepareView(arguments);
//
// case ViewAllCommand.COMMAND_WORD:
// return prepareViewAll(arguments);
//

case LogCommand.COMMAND_WORD:
return new LogCommand(Arrays.asList(arguments.trim().split(" ")));

case DeleteLogCommand.COMMAND_WORD:
return new DeleteLogCommand(Arrays.asList(arguments.trim().split(" ")));

case ViewLogCommand.COMMAND_WORD:
return new ViewLogCommand(Arrays.asList(arguments.trim().split(" ")));

case GoalCommand.COMMAND_WORD:
return new GoalCommand(userInput);

case ExitCommand.COMMAND_WORD:
return new ExitCommand();

case HelpCommand.COMMAND_WORD: // Fallthrough

default:
return new HelpCommand();
// case AddCommand.COMMAND_WORD:
// return prepareAdd(arguments);
//
// case DeleteCommand.COMMAND_WORD:
// return prepareDelete(arguments);
//
// case ClearCommand.COMMAND_WORD:
// return new ClearCommand();
//
// case FindCommand.COMMAND_WORD:
// return prepareFind(arguments);
//
// case ListCommand.COMMAND_WORD:
// return new ListCommand();
//
// case ViewCommand.COMMAND_WORD:
// return prepareView(arguments);
//
// case ViewAllCommand.COMMAND_WORD:
// return prepareViewAll(arguments);
//

case LogCommand.COMMAND_WORD:
return new LogCommand(Arrays.asList(arguments.trim().split(" ")));

case DeleteLogCommand.COMMAND_WORD:
return new DeleteLogCommand(Arrays.asList(arguments.trim().split(" ")));

case ViewLogCommand.COMMAND_WORD:
return new ViewLogCommand(Arrays.asList(arguments.trim().split(" ")));

case MealCommand.COMMAND_WORD:
return new MealCommand(Arrays.asList(arguments.trim().split(" ")));

case GoalCommand.COMMAND_WORD:
return new GoalCommand(userInput);

case ExitCommand.COMMAND_WORD:
return new ExitCommand();

case HelpCommand.COMMAND_WORD: // Fallthrough

default:
return new HelpCommand();
}
}

Expand Down

0 comments on commit 9a4efd0

Please sign in to comment.