Skip to content

Commit

Permalink
A-Packages
Browse files Browse the repository at this point in the history
Divide classes into packages. Put all classes into duke package, organize commands in duke.command
  • Loading branch information
Statspadders committed Jan 26, 2023
1 parent 8462385 commit 8cdf5d4
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 40 deletions.
8 changes: 0 additions & 8 deletions src/main/java/Command.java

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/CommandNotFound.java

This file was deleted.

7 changes: 4 additions & 3 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import java.util.*;
import duke.*;
import duke.command.Command;

import java.io.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Duke {
private Ui ui;
private Storage storage;
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/ListCommand.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

import java.time.LocalDateTime;
public class Deadline extends Task {

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Event.java → src/main/java/duke/Event.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package duke;

import java.time.LocalDateTime;
import java.util.concurrent.atomic.AtomicLong;

public class Event extends Task{
public class Event extends Task {

protected LocalDateTime from;
protected LocalDateTime to;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/Parser.java → src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke;

import duke.command.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.NoSuchElementException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package duke;

import duke.Deadline;
import duke.Event;

import java.io.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/Task.java → src/main/java/duke/Task.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

public class Task {
private boolean mark;
private String value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke;

import duke.Task;

import java.util.ArrayList;
public class TaskList {
private ArrayList<Task> list;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/Todo.java → src/main/java/duke/Todo.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke;

import duke.Task;

public class Todo extends Task {

public Todo(String value,boolean mark) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/Ui.java → src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package duke;

import duke.Task;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import java.io.FileWriter;
package duke.command;

public class AddCommand extends Command{
import duke.Storage;
import duke.TaskList;
import duke.Ui;
import duke.Task;

public class AddCommand extends Command {

private Task task;

Expand All @@ -9,7 +14,7 @@ public AddCommand(Task t) {
}

@Override
public void execute(TaskList tasks,Ui ui,Storage storage) {
public void execute(TaskList tasks, Ui ui, Storage storage) {
tasks.add(this.task);
ui.customMessage("Added : " + task.getValue());
ui.showNumberOfListings(tasks.size());
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package duke.command;

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

public abstract class Command {

public abstract void execute(TaskList tasks, Ui ui, Storage storage);

public boolean isExit() {
return false;
}
}
17 changes: 17 additions & 0 deletions src/main/java/duke/command/CommandNotFound.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package duke.command;

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

public class CommandNotFound extends Command {

public CommandNotFound() {

}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) {
ui.showCommandNotFound();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
public class DeleteCommand extends Command {
package duke.command;

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


public class DeleteCommand extends Command {

private int index;

Expand All @@ -7,7 +14,7 @@ public DeleteCommand(int index) {
}

@Override
public void execute(TaskList tasks,Ui ui,Storage storage) {
public void execute(TaskList tasks, Ui ui, Storage storage) {
ui.customMessage("Noted. I've removed this task: \n");
ui.customMessage(tasks.get(index));
tasks.remove(index);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package duke.command;

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

public class ExitCommand extends Command {

boolean exit;
Expand All @@ -9,7 +15,7 @@ public boolean isExit() {
return this.exit;
}
@Override
public void execute(TaskList tasks,Ui ui,Storage storage) {
public void execute(TaskList tasks, Ui ui, Storage storage) {
ui.byeMessage();
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/duke/command/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package duke.command;

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

public class ListCommand extends Command {

public ListCommand() {

}
@Override
public void execute(TaskList tasks, Ui ui, Storage storage) {
tasks.print();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package duke.command;

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

public class MarkCommand extends Command {

private int index;
Expand All @@ -6,7 +12,7 @@ public MarkCommand(int index) {
this.index = index - 1;
}
@Override
public void execute(TaskList tasks,Ui ui,Storage storage) {
public void execute(TaskList tasks, Ui ui, Storage storage) {
tasks.mark(index);
ui.showMarkSucess(tasks.get(index));
}
Expand Down

0 comments on commit 8cdf5d4

Please sign in to comment.