Skip to content

Commit

Permalink
Merge pull request AY1920S1-CS2113-T14-2#35 from CEGLincoln/master
Browse files Browse the repository at this point in the history
improved checkstyle
  • Loading branch information
CEGLincoln authored Sep 27, 2019
2 parents 28b29a9 + e3a8482 commit addcdf5
Show file tree
Hide file tree
Showing 39 changed files with 288 additions and 392 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="0"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="4"/>
Expand Down
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Fri Sep 27 12:21:41 SGT 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions src/main/.classpath

This file was deleted.

14 changes: 0 additions & 14 deletions src/main/.gitignore

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/.project

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

9 changes: 0 additions & 9 deletions src/main/CONTRIBUTORS.md

This file was deleted.

40 changes: 0 additions & 40 deletions src/main/README.md

This file was deleted.

12 changes: 6 additions & 6 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import duke.ui.Ui;

/**
* MAIN CLASS DUKE, start from main function
* MAIN CLASS DUKE, start from main function.
*/
public class Duke {

private Storage storage;
private TaskList tasks;
private Ui ui;

/**
* The constructor method for Duke
* The constructor method for Duke.
* @param filePath used to specify the location of the file in the hard disc.
*/
public Duke(String filePath) {
Expand All @@ -32,7 +32,7 @@ public Duke(String filePath) {
}

/**
* The execution core of the Duke class
* The execution core of the Duke class.
*/
public void run() {
ui.showWelcome();
Expand All @@ -53,8 +53,8 @@ public void run() {
}

/**
* =============== MAIN FUNCTION ===============
*/
* =============== MAIN FUNCTION ===============.
*/
public static void main(String[] args) {
new Duke("data/tasks.txt").run();
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/duke/command/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@

import duke.exception.DukeException;
import duke.storage.Storage;
import duke.task.*;
import duke.*;
import duke.task.Task;
import duke.task.TaskList;
import duke.ui.Ui;

import java.io.IOException;

/**
* Represents a Command to add a specific {@link Task} in the {@link TaskList}
* Represents a Command to add a specific {@link Task} in the {@link TaskList}.
*/
public class AddCommand extends Command {


private Task task;

/**
* The constructor method for AddCommand.
*
* @param task : the {@link Task} to be added in the list
*/
public AddCommand(Task task) {
this.task = task;
}

/**
* Public method used to add the task in the taskList, and write it on the hard disc
* Public method used to add the task in the taskList, and write it on the hard disc.
*
* @param taskList the {@link TaskList} to be expanded
* @param ui {@link Ui} used for printing the task output
* @param storage {@link Storage} writes in the file on the hard disc
* @throws DukeException
* @throws DukeException Error while adding the command to the duke.txt file
*/
@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import duke.ui.Ui;

/**
* Represents an abstract Command that could be an add, delete, exit, done, find or list
* Represents an abstract Command that could be an add, delete, exit, done, find or list.
*/
public abstract class Command {

abstract public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException;
public abstract void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException;

/**
* Returns the boolean indicating that it is( not) an {@link ExitCommand}
* Returns the boolean indicating that it is( not) an {@link ExitCommand}.
*
* @return false by default
*/
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/duke/command/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.List;

/**
* Represents a specific {@link Command} used to delete a {@link Task} from the {@link TaskList}
* Represents a specific {@link Command} used to delete a {@link Task} from the {@link TaskList}.
*/
public class DeleteCommand extends Command {
private int taskNb;
Expand All @@ -35,7 +35,8 @@ public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeExcept
throw new DukeException("Error while deleting the task from the had disc");
}
ui.showRemovedTask(removed.toString(), taskList.size());
} else
} else {
throw new DukeException("Enter a valid task number after delete, between 1 and " + taskList.size());
}
}
}
5 changes: 3 additions & 2 deletions src/main/java/duke/command/DoneCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import duke.ui.Ui;

/**
* Represents a specific {@link Command} used to mark a {@link Task} as done
* Represents a specific {@link Command} used to mark a {@link Task} as done.
*/
public class DoneCommand extends Command {
private int taskNb;
Expand All @@ -22,7 +22,8 @@ public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeExcept
taskList.markTaskDone(taskNb);
ui.showMarkDone(taskList.getTask(taskNb).toString());
storage.changeContent(taskNb);
} else
} else {
throw new DukeException("Enter a valid task number after done, between 1 and " + taskList.size());
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/duke/command/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
import duke.ui.Ui;

/**
* Represents a specific {@link Command} used to exit the program after the user inputs "bye"
* Represents a specific {@link Command} used to exit the program after the user inputs "bye".
*/
public class ExitCommand extends Command {

@Override
public boolean isExit() {
return true;
}

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) {
System.out.println("\t Bye. Hope to see you again soon!");
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import duke.ui.Ui;

/**
* Represents a specific {@link Command} used to find a String occurring in the {@link TaskList}
* Represents a specific {@link Command} used to find a String occurring in the {@link TaskList}.
*/
public class FindCommand extends Command {

Expand All @@ -28,8 +28,9 @@ public void execute(TaskList taskList, Ui ui, Storage storage) {
}
if (sb.length() == 0) {
System.out.println("No matching tasks found! ");
} else
} else {
System.out.println("\t Here are the matching tasks in your list:");
}
sb.setLength(sb.length() - 1);// to remove the last new line
System.out.println(sb.toString());
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/duke/command/ListCommand.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package duke.command;

import duke.exception.DukeException;
import duke.storage.Storage;
import duke.task.*;
import duke.task.TaskList;
import duke.ui.Ui;

/**
* Represents a specific {@link Command} used to list all the {@link Task}s in the {@link TaskList}
* Represents a specific {@link Command} used to list all the {@link Task}s in the {@link TaskList}.
*/
public class ListCommand extends Command {

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException {
if (taskList.size() == 0)
if (taskList.size() == 0) {
throw new DukeException("No tasks yet!");
else {
} else {
System.out.println("\t Here are the tasks in your list:");
for (int i = 1; i <= taskList.size(); i++) { // looping to print all the saved tasks
ui.showTask("\t " + i + "." + taskList.getTask(i - 1).toString());
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/duke/command/Snooze.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ public class Snooze extends Command {
private String until;
private Date date;

public Snooze(int taskNb, String until){
this.taskNb = taskNb;
this.until=until;
this.date= Parser.stringToDate(until);
public Snooze(int taskNb, String until) {
this.taskNb = taskNb;
this.until = until;
this.date = Parser.stringToDate(until);
}

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws DukeException {
if (taskNb < taskList.size() && taskNb >= 0) {
if(taskList.getTask(taskNb).isDone())
if (taskList.getTask(taskNb).isDone()) {
throw new DukeException("Seems like you've already finished that task, no need to snooze it now");
}
taskList.changeTaskDate(taskNb, until);
ui.showChangedDate(Parser.getDateString(date, until),taskList.getTask(taskNb).toString() );
ui.showChangedDate(Parser.getDateString(date, until),taskList.getTask(taskNb).toString());
storage.changeContent(taskNb);
} else
} else {
throw new DukeException("Enter a valid task number after snooze, between 1 and " + taskList.size());
}
}
}

26 changes: 12 additions & 14 deletions src/main/java/duke/command/ViewCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
import duke.task.Task;
import duke.task.TaskList;
import duke.ui.Ui;

import java.time.LocalDate;
import java.util.Date;


/**
* Represents a specific {@link Command} used to find a String occurring in the {@link TaskList}
* Represents a specific {@link Command} used to find a String occurring in the {@link TaskList}.
*/
public class ViewCommand extends Command {

private final Date Date = new Date();
//private final Date Date = new Date();
private Date toView;

public ViewCommand(Date toView) {
Expand All @@ -28,19 +25,20 @@ public void execute(TaskList taskList, Ui ui, Storage storage) {
try {
for (Task task : taskList.getAllTasks()) {
if ((task.getCurrentDate()).equals(toView)) {
//needs work on this part. comparing of time use Date always takes into account time 0000
//TODO: needs work on this part. comparing of time use Date always takes into account time 0000
sb.append("\t ").append(i++).append(".").append(task.toString());
sb.append(System.lineSeparator());
}
}
if (sb.length() == 0) {
System.out.println("No matching date found! ");
} else
System.out.println("\t Here are the tasks in the requested date:");
sb.setLength(sb.length() - 1);// to remove the last new line
System.out.println(sb.toString());
}catch(Exception e) {

if (sb.length() == 0) {
System.out.println("No matching date found! ");
} else {
System.out.println("\t Here are the tasks in the requested date:");
}
sb.setLength(sb.length() - 1); // to remove the last new line
System.out.println(sb.toString());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
Loading

0 comments on commit addcdf5

Please sign in to comment.