Skip to content

Commit

Permalink
Checked code style
Browse files Browse the repository at this point in the history
  • Loading branch information
chiayuxuan committed Mar 2, 2023
1 parent df925b0 commit c61d0fb
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 36 deletions.
5 changes: 1 addition & 4 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package duke;


import duke.exception.FolderNotFoundException;
import duke.exception.NoKeyException;
import duke.parser.Parser;
Expand All @@ -15,8 +14,7 @@
* to keep track of the different type of tasks in their daily lives
*/
public class Duke {

public static void main(String[] args) throws IOException{
public static void main(String[] args) throws IOException {
Storage storage = new Storage("data", "data/Duke.txt");
Ui ui = new Ui();
Ui.sayHi();
Expand All @@ -40,7 +38,6 @@ public static void main(String[] args) throws IOException{
Ui.displayErrorIOException();
}
} while (!ui.getUserInput().equals("/bye"));

Ui.sayBye();
}
}
1 change: 0 additions & 1 deletion src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
* <code>execute()</code>
*/
public abstract class Command {

public abstract void execute();
}
5 changes: 4 additions & 1 deletion src/main/java/duke/command/DeadlineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import duke.task.Dateline;
import duke.task.TaskList;
import duke.task.Tasks;

/**
* <code>DeadlineCommand</code> object represents a command that executes
* the adding of a new Deadline Task to the TaskList
*/
public class DeadlineCommand extends Command{
public class DeadlineCommand extends Command {
String item;

public DeadlineCommand(String item) {
this.item = item;
}

public void execute() {
String[] taskDate = item.split(" /by ", 2);
Tasks newDeadline = new Dateline(taskDate[0], false, taskDate[1]);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import duke.ui.Ui;
import duke.task.TaskList;
import duke.task.Tasks;

/**
* <code>DeleteCommand</code> object represents a command that executes
* the deletion of a Task object from the TaskList based on its index
*/
public class DeleteCommand extends Command{
public class DeleteCommand extends Command {
protected String item;
public DeleteCommand(String item){

public DeleteCommand(String item) {
this.item = item;
}

public void execute() {
Tasks toDelete = TaskList.getTaskList().get(Integer.parseInt(item) - 1);
Ui.displayDelete(toDelete);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/duke/command/EventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import duke.task.Event;
import duke.task.TaskList;
import duke.task.Tasks;

/**
* <code>EventCommand</code> object represents a command that executes
* the adding of a new Event Task to the TaskList
*/
public class EventCommand extends Command{
public class EventCommand extends Command {
String item;

public EventCommand(String item) {
this.item = item;
}

public void execute() {
String[] eventSlashDate = item.split(" /from | /to ", 3);
Tasks newEvent = new Event(eventSlashDate[0], false, eventSlashDate[1], eventSlashDate[2]);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package duke.command;

import duke.ui.Ui;
/**
* <code>FindCommand</code> object represents a command that executes
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/duke/command/HelpCommand.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package duke.command;

import duke.ui.Ui;

/**
* <code>HelpCommand</code> object represents a command that executes
* and display Help commands
*/
public class HelpCommand extends Command{

public class HelpCommand extends Command {
public HelpCommand() {
}

public void execute() {
Ui.displayHelp();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/command/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class ListCommand extends Command {
public ListCommand() {
}

public void execute() {
Ui.displayList();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/command/MarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import duke.ui.Ui;
import duke.task.TaskList;
import duke.task.Tasks;

/**
* <code>MarkCommand</code> object represents a command that executes
* the marking of tasks in the TaskList
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/duke/command/ToDoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import duke.ui.Ui;
import duke.task.TaskList;
import duke.task.Todo;

/**
* <code>ToDoCommand</code> object represents a command that executes
* the adding of a to-do task in the TaskList
*/
public class ToDoCommand extends Command{
public class ToDoCommand extends Command {
String item;

public ToDoCommand(String item) {
this.item = item;
}

@Override
public void execute() {
Todo newToDo = new Todo(item, false);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/duke/command/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import duke.ui.Ui;
import duke.task.TaskList;
import duke.task.Tasks;

/**
* <code>UnmarkCommand</code> object represents a command that executes
* the un-marking of tasks in the TaskList
*/
public class UnmarkCommand extends Command{

public class UnmarkCommand extends Command {
String item;
public UnmarkCommand(String item){

public UnmarkCommand(String item) {
this.item = item;
}

@Override
public void execute() {
Tasks markTask = TaskList.getTaskList().get(Integer.parseInt(item) - 1);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/duke/exception/FolderNotFoundException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package duke.exception;

public class FolderNotFoundException extends Exception{

public class FolderNotFoundException extends Exception {
}
2 changes: 1 addition & 1 deletion src/main/java/duke/exception/NoKeyException.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package duke.exception;

public class NoKeyException extends Exception{
public class NoKeyException extends Exception {
}
3 changes: 2 additions & 1 deletion src/main/java/duke/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class Parser {
/**
* Parses the input from user
*
* @param userInput Description of task entered by user
* @throws NoKeyException If keywords are missing from user input
*/
Expand Down Expand Up @@ -62,7 +63,7 @@ public static void parseCommand(String userInput) throws NoKeyException {
command.execute();
break;
case "/find":
command= new FindCommand(item);
command = new FindCommand(item);
command.execute();
case "/bye":
break;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/duke/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
public class Storage {
private final String filePath;
private final String folderName;

public Storage(String folderName, String filePath) {
this.filePath = filePath;
this.folderName = folderName;
}

/**
* Loads user data
*
* @throws FolderNotFoundException if folder is not found
* @throws FileNotFoundException if file is not found
* @throws FileNotFoundException if file is not found
*/
public void load() throws FolderNotFoundException, FileNotFoundException {
File folder = new File(folderName);
Expand Down Expand Up @@ -75,6 +77,7 @@ public void load() throws FolderNotFoundException, FileNotFoundException {

/**
* Saves user data
*
* @throws IOException if trouble accessing files
*/
public void save() throws IOException {
Expand All @@ -86,20 +89,20 @@ public void save() throws IOException {
}
fw.close();
}

public void createNewFile() throws IOException {
File f = new File(filePath);
if (f.createNewFile()) {
System.out.println("File created");
}
else
} else
System.out.println("File already exists");
}

public void createNewFolder() {
File folder = new File(folderName);
if(folder.mkdir()) {
if (folder.mkdir()) {
System.out.println("Folder created");
}
else {
} else {
System.out.println("Folder already exists");
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/duke/task/Dateline.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package duke.task;

public class Dateline extends Tasks {
String dueDate;
public Dateline(String item, boolean isMarked, String dueDate) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/duke/task/Event.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package duke.task;

public class Event extends Tasks {
String startDate;
String endDate;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/duke/task/TaskList.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package duke.task;

import java.util.ArrayList;

public class TaskList {
private static int numberOfTasks = 0;
private static final ArrayList<Tasks> taskList = new ArrayList<>();

public static ArrayList<Tasks> getTaskList() {
return taskList;
}

public static int getNumberOfTasks() {
return numberOfTasks;
}

public static void addToList(Tasks task) {
taskList.add(task);
numberOfTasks++;
}

public static void deleteFromList(int pos) {
taskList.remove(pos);
numberOfTasks--;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/duke/task/Tasks.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package duke.task;

import java.util.ArrayList;

public abstract class Tasks {
private String item;
private boolean isMarked;
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/duke/task/Todo.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package duke.task;

public class Todo extends Tasks {



public Todo(String item, boolean isMarked) {
super(item, isMarked);
}

@Override
public String toString() {

return "[T]" + super.toString();
}
}
5 changes: 4 additions & 1 deletion src/main/java/duke/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ public class Ui {
public Ui() {
userInput = null;
}

public String getUserInput() {
return userInput;
}

public static void sayHi() {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
Expand Down Expand Up @@ -55,7 +57,7 @@ public static void displayList() {
Tasks thisTask = TaskList.getTaskList().get(num - 1);
System.out.println("\t " + num + ". " + thisTask);
}
System.out.println(DIVIDER +'\n');
System.out.println(DIVIDER + '\n');

}

Expand All @@ -79,6 +81,7 @@ public static void displayDelete(Tasks task) {
System.out.println("\t Now you have " + (TaskList.getNumberOfTasks() - 1) + " item(s) in your list.\n"
+ DIVIDER + '\n');
}

public static void displayHelp() {
System.out.println(DIVIDER + "\n\t Please read the User Guide in docs/README.md for more help.\n" +
DIVIDER + '\n');
Expand Down

0 comments on commit c61d0fb

Please sign in to comment.