Skip to content

Commit

Permalink
Updated Duke.
Browse files Browse the repository at this point in the history
  • Loading branch information
joelczk committed Mar 1, 2020
1 parent fddea21 commit a8294e9
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 42 deletions.
10 changes: 5 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Duke - User Guide
Duke is a personal task tracker that stores and records your to-dos, deadlines and events.This user guide demonstrates
how to set up Duke and how use the basic features of Duke.
# duke - User Guide
duke is a personal task tracker that stores and records your to-dos, deadlines and events.This user guide demonstrates
how to set up duke and how use the basic features of duke.

## Setting Up
1. Extract the jar folder into an empty folder
2. Enter your preferred terminal and move to the location of the folder
3. Run the Command-Line interface(CLI) with `java -jar Duke.Duke.jar` in your terminal
![Setting up Duke](/images/startup.JPG)
3. Run the Command-Line interface(CLI) with `java -jar duke.duke.jar` in your terminal
![Setting up duke](/images/startup.JPG)

### Features
+ [ToDo](#todo)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import commands.TaskList;
import ui.UI;
import commands.ListCommand;

import java.util.Scanner;

/**
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Exceptions/MissingSearchQueryException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Represents exception when search query is missing for find command
*/
public class MissingSearchQueryException extends DukeExceptions {

public MissingSearchQueryException() {
super();
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public String getFirstWord() {

/**
* Updates String input by user
* Updates command that user wants to run
* @param input String input by user
*/
public void updateInput(String input) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/UI/UI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ui;

/**
* Represents messages displayed by Duke for its user interface
* Represents messages displayed by Duke.Duke for its user interface
* A UI object corresponds to greeting message, leaving message and boundary
*/
public class UI {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/commands/DeadlineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class DeadlineCommand extends TaskList{
protected ErrorMessages errorMessages;
protected ArrayList<Task> tasks;
protected Storage storage;
protected static final int LENGTH_OF_COMMAND = 8;
protected static final String PARAMETER = "/by";

public DeadlineCommand() {
tasks = new ArrayList<Task>();
Expand All @@ -33,8 +31,8 @@ public DeadlineCommand() {
*/
public void addDeadlineToList(String input, int lengthOfCommand) {
tasks = storage.loadTasks();
String description = getDescription(input, lengthOfCommand);
String details = getDetails(input, lengthOfCommand);
String description = getDescription(input,lengthOfCommand);
String details = getDetails(input,lengthOfCommand);
Deadline newDeadline = new Deadline(description, details);
tasks.add(newDeadline);
System.out.println(" Got it!I've added this task:");
Expand All @@ -54,20 +52,22 @@ public void addDeadlineToList(String input, int lengthOfCommand) {
public void addDeadline(String input) throws EmptyStringException, MissingParameterException,
MissingDescriptionsException, MissingDetailsException {
String removeTrailingSpaces = input.trim();
if (removeTrailingSpaces.length() == LENGTH_OF_COMMAND) {
int lengthOfCommand = 8;
String parameter = "/by";
if (removeTrailingSpaces.length() == lengthOfCommand) {
errorMessages.deadlineErrorMessage();
throw new EmptyStringException();
} else if (!removeTrailingSpaces.contains(PARAMETER)) {
} else if (!removeTrailingSpaces.contains(parameter)) {
errorMessages.deadlineErrorMessage();
throw new MissingParameterException();
} else if (isEmptyDescription(input, LENGTH_OF_COMMAND)) {
} else if (isEmptyDescription(input, lengthOfCommand)) {
errorMessages.deadlineErrorMessage();
throw new MissingDescriptionsException();
} else if (isEmptyDetails(input, LENGTH_OF_COMMAND)) {
} else if (isEmptyDetails(input, lengthOfCommand)) {
errorMessages.deadlineErrorMessage();
throw new MissingDetailsException();
} else {
addDeadlineToList(input, LENGTH_OF_COMMAND);
addDeadlineToList(input, lengthOfCommand);
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class DeleteCommand extends TaskList{
protected Storage storage;
protected ArrayList<Task> tasks;
protected ErrorMessages errorMessages;
protected static final int LENGTH_OF_COMMAND = 6;

public DeleteCommand() {
storage = new Storage();
Expand All @@ -30,7 +29,8 @@ public DeleteCommand() {
* @throws OutOfRangeException if index <= 0 or index >size of task list
*/
public void deleteItem(String input) throws IndexFormatException, OutOfRangeException, MissingIndexException {
String numericalIndex = getStringIndex(input,LENGTH_OF_COMMAND);
int lengthOfCommand = 6;
String numericalIndex = getStringIndex(input,lengthOfCommand);
boolean isNumber = isNumeric(numericalIndex);
tasks = storage.loadTasks();
if (numericalIndex.length() == 0) {
Expand All @@ -39,7 +39,7 @@ public void deleteItem(String input) throws IndexFormatException, OutOfRangeExce
} else if (!isNumber) {
errorMessages.deleteErrorMessage();
throw new IndexFormatException();
} else if (isOutOfRange(numericalIndex, tasks)) {
} else if(isOutOfRange(numericalIndex, tasks)) {
errorMessages.deleteErrorMessage();
throw new OutOfRangeException();
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/commands/DoneCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class DoneCommand extends TaskList{
protected Storage storage;
protected ErrorMessages errorMessages;
protected ArrayList<Task> tasks;
protected static final int LENGTH_OF_COMMAND = 4;

public DoneCommand() {
storage = new Storage();
Expand All @@ -25,8 +24,8 @@ public DoneCommand() {
}

/**
* Checks exceptions for done command
* Marks tasks as done
* Check exceptions for done command
* Mark tasks as done
* @param input String input by user
* @param numericalIndex String index by user
* @param isNumber boolean to check if index is number
Expand All @@ -44,7 +43,7 @@ public void checkExceptions(String input, String numericalIndex, boolean isNumbe
} else if (!isNumber) {
errorMessages.doneErrorMessage();
throw new IndexFormatException();
} else if (isOutOfRange(numericalIndex, tasks)) {
} else if(isOutOfRange(numericalIndex, tasks)) {
errorMessages.doneErrorMessage();
throw new OutOfRangeException();
} else if (isCompleted(numericalIndex, tasks)){
Expand All @@ -69,7 +68,8 @@ public void checkExceptions(String input, String numericalIndex, boolean isNumbe
*/
public void markAsDone(String input) throws IndexFormatException, OutOfRangeException, CompletedTaskException,
MissingIndexException {
String numericalIndex = getStringIndex(input, LENGTH_OF_COMMAND);
int lengthOfCommand = 4;
String numericalIndex = getStringIndex(input,lengthOfCommand);
boolean isNumber = isNumeric(numericalIndex);
tasks = storage.loadTasks();
checkExceptions(input, numericalIndex, isNumber, tasks);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/commands/ErrorMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void eventErrorMessage() {
public void deadlineErrorMessage() {
System.out.println(" deadline: Adds deadline tasks");
System.out.println(" Parameters: deadline {DESCRIPTION} /by {DATE/TIME}");
System.out.println(" Example: deadline return book /by Sunday 2359");
System.out.println(" Example: deadline return book /by Sunday");
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/commands/EventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class EventCommand extends TaskList {
protected ArrayList<Task> tasks;
protected Storage storage;
protected ErrorMessages errorMessages;
protected static final int LENGTH_OF_COMMAND = 5;
protected static final String PARAMETER = "/at";

public EventCommand() {
tasks = new ArrayList<Task>();
Expand All @@ -33,8 +31,8 @@ public EventCommand() {
*/
public void addEventToList(String input, int lengthOfCommand) {
tasks = storage.loadTasks();
String description = getDescription(input, lengthOfCommand);
String details = getDetails(input, lengthOfCommand);
String description = getDescription(input,lengthOfCommand);
String details = getDetails(input,lengthOfCommand);
Event newEvent = new Event(description, details);
tasks.add(newEvent);
System.out.println(" Got it!I've added this task:");
Expand All @@ -55,20 +53,22 @@ public void addEventToList(String input, int lengthOfCommand) {
public void addEvent(String input) throws EmptyStringException, MissingParameterException,
MissingDescriptionsException, MissingDetailsException {
String removeTrailingSpaces = input.trim();
if (removeTrailingSpaces.length() == LENGTH_OF_COMMAND) {
int lengthOfCommand = 5;
String parameter = "/at";
if (removeTrailingSpaces.length() == lengthOfCommand) {
errorMessages.eventErrorMessage();
throw new EmptyStringException();
} else if (!removeTrailingSpaces.contains(PARAMETER)) {
} else if (!removeTrailingSpaces.contains(parameter)) {
errorMessages.eventErrorMessage();
throw new MissingParameterException();
} else if (isEmptyDescription(input, LENGTH_OF_COMMAND)) {
} else if (isEmptyDescription(input, lengthOfCommand)) {
errorMessages.eventErrorMessage();
throw new MissingDescriptionsException();
} else if (isEmptyDetails(input, LENGTH_OF_COMMAND)) {
} else if (isEmptyDetails(input, lengthOfCommand)) {
errorMessages.eventErrorMessage();
throw new MissingDetailsException();
} else {
addEventToList(input, LENGTH_OF_COMMAND);
addEventToList(input, lengthOfCommand);
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class FindCommand extends TaskList{
protected Storage storage;
protected ArrayList<Task> tasks;
protected ErrorMessages errorMessages;
protected static final int LENGTH_OF_COMMAND = 4;

public FindCommand() {
storage = new Storage();
Expand Down Expand Up @@ -63,7 +62,8 @@ public void printSearchResults(String description) {
* @throws MissingSearchQueryException if search query is missing
*/
public void findSearchQuery(String input) throws MissingSearchQueryException {
String searchQuery = input.substring(LENGTH_OF_COMMAND).trim();
int lengthOfCommand = 4;
String searchQuery = input.substring(lengthOfCommand).trim();
if (searchQuery.length() == 0) {
errorMessages.findErrorMessage();
throw new MissingSearchQueryException();
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/commands/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import java.util.ArrayList;
import tasks.Task;

/**
* Represents the helper functions used by commands package
*/
public class TaskList {

public TaskList() {}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/commands/ToDoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class ToDoCommand {
protected ErrorMessages errorMessages;
protected ArrayList<Task> tasks;
protected Storage storage;
protected static final int LENGTH_OF_COMMAND = 4;

public ToDoCommand() {
tasks = new ArrayList<Task>();
Expand All @@ -28,8 +27,9 @@ public ToDoCommand() {
*/
public void addToDo(String input) throws MissingDescriptionsException {
String removeTrailingSpaces = input.trim();
int lengthOfCommand = 4;
tasks = storage.loadTasks();
if (removeTrailingSpaces.length() == LENGTH_OF_COMMAND) {
if (removeTrailingSpaces.length() == lengthOfCommand) {
errorMessages.toDoErrorMessage();
throw new MissingDescriptionsException();
} else {
Expand Down

0 comments on commit a8294e9

Please sign in to comment.