Skip to content

Commit

Permalink
tidy up packages (nusCS2113-AY1920S1#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
limsiying authored Sep 25, 2019
1 parent f622e7b commit 55543ca
Show file tree
Hide file tree
Showing 30 changed files with 243 additions and 209 deletions.
11 changes: 6 additions & 5 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import duke.command.Command;
import duke.command.Storage;
import duke.command.Ui;
import duke.dukeexception.DukeException;
import duke.task.TaskList;
import duchess.logic.commands.Command;
import duchess.logic.parser.Parser;
import duchess.storage.Storage;
import duchess.ui.Ui;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.TaskList;

public class Duke {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package duke.command;
package duchess.logic.commands;

import duchess.storage.Storage;
import duchess.storage.task.TaskList;
import duchess.storage.task.Task;
import duchess.storage.task.Deadline;
import duchess.logic.commands.exceptions.DukeException;
import duchess.ui.Ui;

import duke.task.TaskList;
import duke.task.Task;
import duke.task.Deadline;
import duke.dukeexception.DukeException;
import java.util.List;

public class AddDeadlineCommand extends Command {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package duke.command;
package duchess.logic.commands;

import duke.dukeexception.DukeException;
import duke.task.Event;
import duke.task.TaskList;
import duchess.storage.Storage;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.Event;
import duchess.storage.task.TaskList;
import duchess.ui.Ui;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package duke.command;
package duchess.logic.commands;

import duchess.storage.Storage;
import duchess.storage.task.TaskList;
import duchess.storage.task.Todo;
import duchess.storage.task.Task;
import duchess.logic.commands.exceptions.DukeException;
import duchess.ui.Ui;

import duke.task.TaskList;
import duke.task.Todo;
import duke.task.Task;
import duke.dukeexception.DukeException;
import java.util.List;

public class AddTodoCommand extends Command {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package duke.command;
package duchess.logic.commands;

import duke.task.TaskList;
import duke.dukeexception.DukeException;
import duchess.storage.Storage;
import duchess.storage.task.TaskList;
import duchess.logic.commands.exceptions.DukeException;
import duchess.ui.Ui;

public class ByeCommand extends Command {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package duke.command;
package duchess.logic.commands;

import duke.dukeexception.DukeException;
import duke.task.TaskList;
import duchess.storage.Storage;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.TaskList;
import duchess.ui.Ui;

public abstract class Command {
protected boolean isExit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package duke.command;
package duchess.logic.commands;

import duke.task.TaskList;
import duke.task.Task;
import duke.dukeexception.DukeException;
import duchess.storage.Storage;
import duchess.storage.task.TaskList;
import duchess.storage.task.Task;
import duchess.logic.commands.exceptions.DukeException;
import duchess.ui.Ui;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package duke.command;
package duchess.logic.commands;

import duchess.storage.Storage;
import duchess.storage.task.TaskList;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.Task;
import duchess.ui.Ui;

import duke.task.TaskList;
import duke.dukeexception.DukeException;
import duke.task.Task;
import java.util.List;

public class DoneCommand extends Command {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package duke.command;
package duchess.logic.commands;

import duchess.storage.Storage;
import duchess.storage.task.Task;
import duchess.storage.task.TaskList;
import duchess.logic.commands.exceptions.DukeException;
import duchess.ui.Ui;

import duke.task.Task;
import duke.task.TaskList;
import duke.dukeexception.DukeException;
import java.util.List;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package duke.command;
package duchess.logic.commands;

import duke.dukeexception.DukeException;
import duke.task.TaskList;
import duchess.storage.Storage;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.TaskList;
import duchess.ui.Ui;

public class ListCommand extends Command {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
package duke.command;

import duke.dukeexception.DukeException;
import duke.task.Deadline;
import duke.task.Task;
import duke.task.TaskList;

import java.util.ArrayList;
import java.util.List;

/**
* Searches Tasklist and filters out deadline objects.
*/
public class ReminderCommand extends Command {

/**
* Displays Deadline objects to user.
*
* @param taskList List containing tasks
* @param ui Userinterface object
* @param storage Storage object
* @throws DukeException Exception thrown when storage not found
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException {
List<Task> reminderList = addDeadlines(taskList);
display(reminderList, ui);
}

/**
* Returns a List of Task objects.
* Adds objects of type Deadline to reminderList.
*
* @param taskList of user inputs
*/
private List<Task> addDeadlines(TaskList taskList) {
ArrayList<Task> reminderList = new ArrayList<>();
for (Task task : taskList.getTasks()) {
if (task instanceof Deadline) {
reminderList.add(task);
}
}
return reminderList;
}

/**
* Displays deadlines to user.
*/
private void display(List<Task> reminderList, Ui ui) {
if (reminderList.size() == 0) {
ui.showNoDeadlines();
} else {
ui.showDeadlines(reminderList);
}
}
package duchess.logic.commands;

import duchess.storage.Storage;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.Deadline;
import duchess.storage.task.Task;
import duchess.storage.task.TaskList;
import duchess.ui.Ui;

import java.util.ArrayList;
import java.util.List;

/**
* Searches Tasklist and filters out deadline objects.
*/
public class ReminderCommand extends Command {

/**
* Displays Deadline objects to user.
*
* @param taskList List containing tasks
* @param ui Userinterface object
* @param storage Storage object
* @throws DukeException Exception thrown when storage not found
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException {
List<Task> reminderList = addDeadlines(taskList);
display(reminderList, ui);
}

/**
* Returns a List of Task objects.
* Adds objects of type Deadline to reminderList.
*
* @param taskList of user inputs
*/
private List<Task> addDeadlines(TaskList taskList) {
ArrayList<Task> reminderList = new ArrayList<>();
for (Task task : taskList.getTasks()) {
if (task instanceof Deadline) {
reminderList.add(task);
}
}
return reminderList;
}

/**
* Displays deadlines to user.
*/
private void display(List<Task> reminderList, Ui ui) {
if (reminderList.size() == 0) {
ui.showNoDeadlines();
} else {
ui.showDeadlines(reminderList);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package duke.command;
package duchess.logic.commands;

import duke.dukeexception.DukeException;
import duke.task.Snoozeable;
import duke.task.Task;
import duke.task.TaskList;
import duchess.storage.Storage;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.Snoozeable;
import duchess.storage.task.Task;
import duchess.storage.task.TaskList;
import duchess.ui.Ui;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package duke.command;
package duchess.logic.commands;

import duke.dukeexception.DukeException;
import duke.task.Task;
import duke.task.TaskList;
import duchess.model.Schedule;
import duchess.storage.Storage;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.Task;
import duchess.storage.task.TaskList;
import duchess.ui.Ui;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package duke.dukeexception;
package duchess.logic.commands.exceptions;

public class DukeException extends Exception {
public DukeException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import duke.command.AddDeadlineCommand;
import duke.command.AddEventCommand;
import duke.command.AddTodoCommand;
import duke.command.ByeCommand;
import duke.command.Command;
import duke.command.DeleteCommand;
import duke.command.DoneCommand;
import duke.command.FindCommand;
import duke.command.ListCommand;
import duke.command.ReminderCommand;
import duke.command.SnoozeCommand;
import duke.command.ViewScheduleCommand;
import duke.dukeexception.DukeException;
package duchess.logic.parser;

import duchess.logic.commands.AddDeadlineCommand;
import duchess.logic.commands.AddEventCommand;
import duchess.logic.commands.AddTodoCommand;
import duchess.logic.commands.ByeCommand;
import duchess.logic.commands.Command;
import duchess.logic.commands.DeleteCommand;
import duchess.logic.commands.DoneCommand;
import duchess.logic.commands.FindCommand;
import duchess.logic.commands.ListCommand;
import duchess.logic.commands.ReminderCommand;
import duchess.logic.commands.SnoozeCommand;
import duchess.logic.commands.ViewScheduleCommand;
import duchess.logic.commands.exceptions.DukeException;

import java.util.Arrays;
import java.util.List;

class Parser {
public class Parser {
/**
* Returns the command to execute after parsing user input.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package duke.command;
package duchess.model;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.command;
package duchess.storage;

import duke.dukeexception.DukeException;
import duke.task.TaskList;
import duchess.logic.commands.exceptions.DukeException;
import duchess.storage.task.TaskList;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.task;
package duchess.storage.task;

import duke.dukeexception.DukeException;
import duke.command.Schedule;
import duchess.logic.commands.exceptions.DukeException;
import duchess.model.Schedule;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.task;
package duchess.storage.task;

import duke.dukeexception.DukeException;
import duke.command.Schedule;
import duchess.logic.commands.exceptions.DukeException;
import duchess.model.Schedule;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package duke.task;
package duchess.storage.task;

public interface Snoozeable {
void snooze();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package duke.task;
package duchess.storage.task;

import duke.command.Schedule;
import duchess.model.Schedule;

import java.io.Serializable;
import java.util.Date;
Expand Down
Loading

0 comments on commit 55543ca

Please sign in to comment.