diff --git a/src/main/java/seedu/elisa/logic/commands/AddCommand.java b/src/main/java/seedu/elisa/logic/commands/AddCommand.java index ff6ff7ad544..1cc8f00d4b3 100644 --- a/src/main/java/seedu/elisa/logic/commands/AddCommand.java +++ b/src/main/java/seedu/elisa/logic/commands/AddCommand.java @@ -53,8 +53,7 @@ public boolean equals(Object other) { @Override public void reverse(ItemModel model) throws CommandException { - model.removeItem(toAdd); - model.getItemStorage().remove(toAdd); + model.deleteItem(toAdd); if (toAdd.hasAutoReschedule()) { Event event = toAdd.getEvent().get(); // if autoReschedule is present, item definitely has an event. diff --git a/src/main/java/seedu/elisa/model/ItemModelManager.java b/src/main/java/seedu/elisa/model/ItemModelManager.java index a1f5f0db78a..de2becfee87 100644 --- a/src/main/java/seedu/elisa/model/ItemModelManager.java +++ b/src/main/java/seedu/elisa/model/ItemModelManager.java @@ -249,40 +249,22 @@ public String getJoke() { * @return the item that was removed */ public Item removeItem(int index) { - Item item = visualList.removeItemFromList(index); + Item item = visualList.get(index); return removeItem(item); } - /** - * remove the given item from the list(s) - * */ - - public Item removeItem(Item item) { - Item removedItem = visualList.removeItemFromList(item); - if (visualList instanceof TaskList) { - taskList.removeItemFromList(removedItem); - } else if (visualList instanceof EventList) { - eventList.removeItemFromList(removedItem); - } else if (visualList instanceof ReminderList) { - reminderList.removeItemFromList(removedItem); - } else { - // never reached here as there are only three variants for the visualList - } - activeReminders.remove(item); - futureReminders.remove(item); - return removedItem; - } - /** * Removes an item from a list. Used for edit command to remove the old item. * @param item the item to be removed from the list * @return the item that is removed. */ - private Item removeFromSeparateList(Item item) { + public Item removeItem(Item item) { visualList.remove(item); taskList.remove(item); eventList.remove(item); reminderList.remove(item); + futureReminders.remove(item); + activeReminders.remove(item); return item; } @@ -311,13 +293,8 @@ public Item deleteItem(int index) { * @return the item that was deleted from the program */ public Item deleteItem(Item item) { - visualList.removeItemFromList(item); itemStorage.remove(item); - taskList.removeItemFromList(item); - eventList.removeItemFromList(item); - reminderList.removeItemFromList(item); - activeReminders.remove(item); - futureReminders.remove(item); + removeItem(item); if (priorityMode.getValue()) { getNextTask(); } diff --git a/src/main/java/seedu/elisa/model/JokeList.java b/src/main/java/seedu/elisa/model/JokeList.java index f60e7d6037c..b33bc3192f6 100644 --- a/src/main/java/seedu/elisa/model/JokeList.java +++ b/src/main/java/seedu/elisa/model/JokeList.java @@ -1,19 +1,18 @@ package seedu.elisa.model; -import java.io.File; -import java.io.FileNotFoundException; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Random; -import java.util.Scanner; /** * List of jokes to pick and display * */ public class JokeList { - private Path jokeFile = Paths.get("data", "jokes.txt"); + private InputStream jokeFile = JokeList.class.getResourceAsStream("/documents/jokes.txt"); private ArrayList jokes; private Random rng; @@ -21,14 +20,14 @@ public JokeList() { jokes = new ArrayList<>(); rng = new Random(); - File file = jokeFile.toFile(); + BufferedReader r = new BufferedReader(new InputStreamReader(jokeFile)); try { - Scanner sc = new Scanner(file); - while (sc.hasNext()) { - jokes.add(sc.nextLine()); + String l; + while ((l = r.readLine()) != null) { + jokes.add(l); } - } catch (FileNotFoundException e) { + } catch (IOException e) { e.printStackTrace(); } } diff --git a/src/main/java/seedu/elisa/model/UserPrefs.java b/src/main/java/seedu/elisa/model/UserPrefs.java index 9a16ca304d9..01ceda79022 100644 --- a/src/main/java/seedu/elisa/model/UserPrefs.java +++ b/src/main/java/seedu/elisa/model/UserPrefs.java @@ -14,7 +14,7 @@ public class UserPrefs implements ReadOnlyUserPrefs { private GuiSettings guiSettings = new GuiSettings(); - private Path addressBookFilePath = Paths.get("data" , "addressbook.json"); + private Path addressBookFilePath = Paths.get("data" , "itemstorage.json"); /** * Creates a {@code UserPrefs} with default values. diff --git a/src/main/java/seedu/elisa/ui/MainWindow.java b/src/main/java/seedu/elisa/ui/MainWindow.java index affc4f3af1b..37986bf43f6 100644 --- a/src/main/java/seedu/elisa/ui/MainWindow.java +++ b/src/main/java/seedu/elisa/ui/MainWindow.java @@ -53,9 +53,9 @@ public class MainWindow extends UiPart { private final Logger logger = LogsCenter.getLogger(getClass()); private final Image redElisa = new Image(getClass().getClassLoader() - .getResource("images/FocusElisa.png").toString()); + .getResource("images/FocusElisa.PNG").toString()); private final Image blueElisa = new Image(getClass().getClassLoader() - .getResource("images/ElisaImageWithoutWords.png").toString()); + .getResource("images/ElisaImageWithoutWords.PNG").toString()); private Stage primaryStage; private Logic logic; diff --git a/src/main/java/seedu/elisa/ui/UiManager.java b/src/main/java/seedu/elisa/ui/UiManager.java index fab3ca46da2..5ac6011675d 100644 --- a/src/main/java/seedu/elisa/ui/UiManager.java +++ b/src/main/java/seedu/elisa/ui/UiManager.java @@ -20,7 +20,7 @@ public class UiManager implements Ui { public static final String ALERT_DIALOG_PANE_FIELD_ID = "alertDialogPane"; private static final Logger logger = LogsCenter.getLogger(UiManager.class); - private static final String ICON_APPLICATION = "/images/ElisaIcon.png"; + private static final String ICON_APPLICATION = "/images/ElisaIcon.PNG"; private Logic logic; private MainWindow mainWindow; diff --git a/data/jokes.txt b/src/main/resources/documents/jokes.txt similarity index 100% rename from data/jokes.txt rename to src/main/resources/documents/jokes.txt diff --git a/src/main/resources/images/Completed.png b/src/main/resources/images/Completed.PNG similarity index 100% rename from src/main/resources/images/Completed.png rename to src/main/resources/images/Completed.PNG diff --git a/src/main/resources/images/ElisaIcon.png b/src/main/resources/images/ElisaIcon.PNG similarity index 100% rename from src/main/resources/images/ElisaIcon.png rename to src/main/resources/images/ElisaIcon.PNG diff --git a/src/main/resources/images/ElisaImageWithoutWords.png b/src/main/resources/images/ElisaImageWithoutWords.PNG similarity index 100% rename from src/main/resources/images/ElisaImageWithoutWords.png rename to src/main/resources/images/ElisaImageWithoutWords.PNG diff --git a/src/main/resources/images/ElisaName.png b/src/main/resources/images/ElisaName.PNG similarity index 100% rename from src/main/resources/images/ElisaName.png rename to src/main/resources/images/ElisaName.PNG diff --git a/src/main/resources/images/EventIcon.png b/src/main/resources/images/EventIcon.PNG similarity index 100% rename from src/main/resources/images/EventIcon.png rename to src/main/resources/images/EventIcon.PNG diff --git a/src/main/resources/images/FocusElisa.png b/src/main/resources/images/FocusElisa.PNG similarity index 100% rename from src/main/resources/images/FocusElisa.png rename to src/main/resources/images/FocusElisa.PNG diff --git a/src/main/resources/images/address_book_32.png b/src/main/resources/images/address_book_32.PNG similarity index 100% rename from src/main/resources/images/address_book_32.png rename to src/main/resources/images/address_book_32.PNG diff --git a/src/main/resources/images/calendar.png b/src/main/resources/images/calendar.PNG similarity index 100% rename from src/main/resources/images/calendar.png rename to src/main/resources/images/calendar.PNG diff --git a/src/main/resources/images/clock.png b/src/main/resources/images/clock.PNG similarity index 100% rename from src/main/resources/images/clock.png rename to src/main/resources/images/clock.PNG diff --git a/src/main/resources/images/fail.png b/src/main/resources/images/fail.PNG similarity index 100% rename from src/main/resources/images/fail.png rename to src/main/resources/images/fail.PNG diff --git a/src/main/resources/images/help_icon.png b/src/main/resources/images/help_icon.PNG similarity index 100% rename from src/main/resources/images/help_icon.png rename to src/main/resources/images/help_icon.PNG diff --git a/src/main/resources/images/info_icon.png b/src/main/resources/images/info_icon.PNG similarity index 100% rename from src/main/resources/images/info_icon.png rename to src/main/resources/images/info_icon.PNG diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index cbeb0945d18..2d8086ab14c 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -16,7 +16,7 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/src/test/java/seedu/elisa/commons/util/AppUtilTest.java b/src/test/java/seedu/elisa/commons/util/AppUtilTest.java index 38e139d5718..f520643c4c1 100644 --- a/src/test/java/seedu/elisa/commons/util/AppUtilTest.java +++ b/src/test/java/seedu/elisa/commons/util/AppUtilTest.java @@ -9,7 +9,7 @@ public class AppUtilTest { @Test public void getImage_exitingImage() { - assertNotNull(AppUtil.getImage("/images/address_book_32.png")); + assertNotNull(AppUtil.getImage("/images/address_book_32.PNG")); } @Test