Skip to content

Commit

Permalink
Move files into packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromesyl committed Aug 25, 2021
1 parent 389a4ee commit 1c3cf79
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 36 deletions.
7 changes: 0 additions & 7 deletions src/main/data/duke.txt
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
T | 1 | read book
D | 0 | return book | 2019-10-10
T | 0 | join sports club
T | 1 | test this
T | 1 | this thing
D | 0 | homework | 2020-10-02
E | 0 | birthday | 2020-12-05 13:00
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package duke;
package duke.Command;

import duke.DukeException;
import duke.Storage;
import duke.TaskList;
import duke.Ui;
import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package duke;
package duke.Command;

import duke.DukeException;
import duke.Storage;
import duke.TaskList;
import duke.Ui;

public abstract class Command {
public abstract void runCommand(TaskList taskList, Ui ui, Storage storage) throws DukeException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package duke;
package duke.Command;

import duke.DukeException;
import duke.Storage;
import duke.TaskList;
import duke.Ui;

public class DeleteCommand extends Command {
private int index;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package duke;
package duke.Command;

import duke.DukeException;
import duke.Storage;
import duke.TaskList;
import duke.Ui;

public class DoneCommand extends Command {
private int index;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package duke;
package duke.Command;

public class ExitCommand extends Command{
import duke.Command.Command;
import duke.DukeException;
import duke.Storage;
import duke.TaskList;
import duke.Ui;

public class ExitCommand extends Command {

@Override
public void runCommand(TaskList taskList, Ui ui, Storage storage) throws DukeException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
package duke;
package duke.Command;

import duke.Command.Command;
import duke.DukeException;
import duke.Storage;
import duke.TaskList;
import duke.Ui;

public class ListCommand extends Command {

Expand Down
19 changes: 1 addition & 18 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
package duke;

import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
import duke.task.Todo;

import java.io.FileNotFoundException;
import java.io.File;
import java.io.FileWriter;
import java.nio.file.Files;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

import java.time.format.DateTimeParseException;

import java.util.ArrayList;
import java.util.Scanner;
import duke.Command.Command;

public class Duke {
private Storage storage;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package duke;

import java.io.IOException;
import java.util.Scanner;
import duke.Command.*;

public class Parser {

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/duke/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public int getSize() {
return tasks.size();
}

public Task getTask(int index) {
return tasks.get(index);
public Task getTask(int index) throws DukeException {
try {
return tasks.get(index);
} catch (IndexOutOfBoundsException e) {
throw new DukeException("Invalid Task. Please try again.");
}
}

public void addTask(Task task) {
Expand Down

0 comments on commit 1c3cf79

Please sign in to comment.