Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
6a815ae
implement echoes
Decaxical Jan 25, 2022
a716a9b
List ability
Decaxical Jan 25, 2022
bb75b50
Added mark and unmark task functionality
Decaxical Jan 26, 2022
8e19494
Implement Todo, Event, Deadline functionality
Decaxical Jan 30, 2022
b38e28d
Text-UI-Testing update
Decaxical Jan 30, 2022
fafdd62
Implemented DukeExceptions
Decaxical Feb 1, 2022
eb04bc7
Added delete commannd
Decaxical Feb 1, 2022
74a00d1
Added Saving functionality
Decaxical Feb 8, 2022
738ca50
Update Duke to recognize dates
Decaxical Feb 11, 2022
a2ce70c
Merge branch 'branch-Level-8'
Decaxical Feb 11, 2022
3f0f903
Revert "Merge branch 'branch-Level-8'"
Decaxical Feb 14, 2022
e6993ef
Revert "Added Saving functionality"
Decaxical Feb 14, 2022
7f7c12f
Revert "Update Duke to recognize dates"
Decaxical Feb 14, 2022
39e0e6f
Merge branch 'branch-Level-7'
Decaxical Feb 14, 2022
12cc23e
Revert "Revert "Merge branch 'branch-Level-8'""
Decaxical Feb 14, 2022
5aef82a
Revert "Revert "Added Saving functionality""
Decaxical Feb 14, 2022
6925a3a
Storage save and load datetime
Decaxical Feb 14, 2022
53d55f8
Extracted TextUI, Parser, Tasklist and Command into separate classes
Decaxical Feb 16, 2022
5ecd726
Cleaned up imports and packages
Decaxical Feb 16, 2022
c910dac
Added JUnit tests for parser and Task
Decaxical Feb 17, 2022
c3ab2f1
Changed compile version from java 15 to java 11
Decaxical Feb 17, 2022
0ccd1dc
minor UI improvement
Decaxical Feb 17, 2022
788eebd
Added Java documentation
Decaxical Feb 17, 2022
cef55d4
Updated to uphold Coding Standard
Decaxical Feb 17, 2022
2cccc29
Added parseSaveDateTime
Decaxical Feb 17, 2022
299caf5
Added FindCommand
Decaxical Feb 17, 2022
8b673af
Merge branch 'branch-A-JavaDoc'
Decaxical Feb 18, 2022
60c99d4
Merge branch 'branch-Level-9'
Decaxical Feb 18, 2022
8c11904
Updated Javadoc
Decaxical Feb 18, 2022
60aedd2
Merge branch 'add-gradle-support'
Decaxical Feb 18, 2022
7812b25
Updated gradle
Decaxical Feb 18, 2022
1fc28b2
Add GUI prototype
Decaxical Feb 19, 2022
75e98b3
Add Assertions
Decaxical Feb 19, 2022
eb1d240
Update Code Quality
Decaxical Feb 19, 2022
81ef77c
Revert "Update Code Quality"
Decaxical Feb 19, 2022
ee58544
Revert "Update Code Quality"
Decaxical Feb 19, 2022
f9b1f09
Revert "Add Assertions"
Decaxical Feb 19, 2022
66a2967
Merge branch 'branch-A-Assertions' of https://github.com/Decaxical/ip…
Decaxical Feb 19, 2022
3b45581
Update Code Quality
Decaxical Feb 19, 2022
348dc72
Merge pull request #2 from Decaxical/branch-A-CodeQuality
Decaxical Feb 19, 2022
6aa3f90
Merge pull request #3 from Decaxical/branch-A-Assertions
Decaxical Feb 19, 2022
fdc06cf
Added Sort Functionality
Decaxical Feb 21, 2022
0ea16b8
Minor update for SortCommand
Decaxical Feb 21, 2022
d1cc88c
Updated User Guide
Decaxical Feb 21, 2022
ad7f24e
Set theme jekyll-theme-slate
Decaxical Feb 21, 2022
95a600b
Set theme jekyll-theme-slate
Decaxical Feb 21, 2022
42acf6d
Set theme jekyll-theme-minimal
Decaxical Feb 21, 2022
8b5e894
Update README.md
Decaxical Feb 21, 2022
fdd2bc2
Set theme jekyll-theme-midnight
Decaxical Feb 21, 2022
e187739
Update User Guide
Decaxical Feb 21, 2022
1467de4
Update User Guide
Decaxical Feb 21, 2022
ace9d19
Update User Guide format
Decaxical Feb 21, 2022
bc87403
Improved GUI
Decaxical Feb 21, 2022
d830809
Added UI.png
Decaxical Feb 21, 2022
5b8d45b
Minor update to User Guide format
Decaxical Feb 21, 2022
4ac0813
Minor bug fix update
Decaxical Feb 21, 2022
11ca41c
Update User Guide
Decaxical Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
```
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

153 changes: 153 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
package duke;

import duke.exceptions.DukeInvalidArgumentException;
import duke.tasks.*;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps list all imported classes explicitly?

import java.util.Scanner;
import java.util.ArrayList;

public class Duke {

private static ArrayList<Task> taskList;
private static Scanner getUserInput;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getUserInput sounds like a method name. Perhaps consider changing it to

Suggested change
private static Scanner getUserInput;
private static Scanner sc;


private static void initialize(){
taskList = new ArrayList<Task>();
getUserInput = new Scanner(System.in);
}

public static void displayTaskList() {
if (taskList.isEmpty()) {
System.out.println("Your current task list is empty");
return;
}
int taskCounter = 1;
System.out.println("These are the current tasks in your list:");
for(Task task:taskList) {
System.out.printf("%d. %s \n", taskCounter, task.toString());
taskCounter++;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can use a TaskList object to separate out each user's task lists and bundle away all related methods like displaying/adding/removing to the list?


public static void displayTaskAdd(Task addedTask){
System.out.println("This task has been added as requested:");
System.out.println(addedTask.toString());
System.out.printf("You now have %d item(s) in your list\n", taskList.size());
}

public static void displayTaskDelete(Task deletedTask){
System.out.println("As you wish. The following task has been removed");
System.out.println(deletedTask.toString());
System.out.printf("You now have %d item(s) in your list\n", taskList.size());
}

public static String[] parseArguments(String[] arguments) throws DukeInvalidArgumentException {
if (arguments.length < 2) {
throw new DukeInvalidArgumentException("There appears to be invalid arguments");
}

return arguments[1].split(" /([Aa][Tt]|[Bb][Yy]) ", 2);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe have some JavaDoc comments to explain non-trivial public methods?


public static void commandProcessor() {
String userInput = getUserInput.nextLine();
String[] parsedUserInput = userInput.split(" ", 2);
switch (parsedUserInput[0].toLowerCase()) {
case "" :
commandProcessor();
break;
case "bye":
System.out.println("Till we meet again");
break;
case "list":
displayTaskList();
commandProcessor();
break;
case "mark":
int taskToMarkNumber = Integer.parseInt(parsedUserInput[1]);
if (taskToMarkNumber > taskList.size()) {
System.out.println("I am afraid that's an invalid task! Please check your task number");
commandProcessor();
break;
}
Task taskToMark = taskList.get(taskToMarkNumber - 1);
taskToMark.markAsDone();
System.out.println("Duly noted. The following task has been marked as done");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can add a method displayMark for the print message as what you did earlier 👍

System.out.println(taskToMark.toString());
commandProcessor();
break;
case "unmark":
int taskToUnmarkNumber = Integer.parseInt(parsedUserInput[1]);
if (taskToUnmarkNumber > taskList.size()) {
System.out.println("I am afraid that's an invalid task! Please check your task number");
commandProcessor();
break;
}
Task taskToUnmark = taskList.get(taskToUnmarkNumber - 1);
taskToUnmark.markAsNotDone();
System.out.println("Very well. The following task has been marked as undone");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above displayUnmark

System.out.println(taskToUnmark.toString());
commandProcessor();
break;
case "todo":
try {
String[] parsedArguments = parseArguments(parsedUserInput);
Todo newTodo = new Todo(parsedArguments[0]);
taskList.add(newTodo);
displayTaskAdd(newTodo);
} catch (DukeInvalidArgumentException e) {
System.out.println(e.getMessage());
}
commandProcessor();
break;
case "deadline":
try {
String[] parsedArguments = parseArguments(parsedUserInput);
Deadline newDeadline = new Deadline(parsedArguments[0], parsedArguments[1]);
taskList.add(newDeadline);
displayTaskAdd(newDeadline);
} catch (DukeInvalidArgumentException e) {
System.out.println(e.getMessage());
}
commandProcessor();
break;
case "event":
try {
String[] parsedArguments = parseArguments(parsedUserInput);
Event newEvent = new Event(parsedArguments[0], parsedArguments[1]);
taskList.add(newEvent);
displayTaskAdd(newEvent);
} catch (DukeInvalidArgumentException e) {
System.out.println(e.getMessage());
}
commandProcessor();
break;
case "delete":
int taskToDeleteNumber = Integer.parseInt(parsedUserInput[1]);
if (taskToDeleteNumber > taskList.size()) {
System.out.println("I am afraid that's an invalid task! Please check your task number");
commandProcessor();
break;
}
Task taskToDelete = taskList.get(taskToDeleteNumber - 1);
taskList.remove(taskToDeleteNumber - 1);
displayTaskDelete(taskToDelete);
commandProcessor();
break;
default:
System.out.println("I am unable to comprehend your request. Please try again");
commandProcessor();
}
}

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("How may I assist you?");
initialize();
commandProcessor();
}
}
7 changes: 7 additions & 0 deletions src/main/java/duke/exceptions/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package duke.exceptions;

public class DukeException extends Exception{
public DukeException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package duke.exceptions;

public class DukeInvalidArgumentException extends DukeException{
public DukeInvalidArgumentException(String message) {
super(message);
}
}
16 changes: 16 additions & 0 deletions src/main/java/duke/tasks/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package duke.tasks;

public class Deadline extends Task{

private String date;

public Deadline(String content, String date) {
super(content);
this.date = date;
}

@Override
public String toString() {
return String.format("[D]%s (by: %s)", super.toString(), this.date);
}
}
16 changes: 16 additions & 0 deletions src/main/java/duke/tasks/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package duke.tasks;

public class Event extends Task{

private String date;

public Event(String content, String date) {
super(content);
this.date = date;
}

@Override
public String toString() {
return String.format("[E]%s (at: %s)", super.toString(), this.date);
}
}
24 changes: 24 additions & 0 deletions src/main/java/duke/tasks/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package duke.tasks;

public class Task {
String content;
boolean markedDone = false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean var can be named as isDone

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
boolean markedDone = false;
boolean isMarkedDone = false;


public Task(String content) {
this.content = content;
}

public void markAsDone() {
this.markedDone = true;
}

public void markAsNotDone() {
this.markedDone = false;
}

@Override
public String toString() {
return "[" + (this.markedDone ? "X" : " ") + "] " + this.content;
}

}
12 changes: 12 additions & 0 deletions src/main/java/duke/tasks/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package duke.tasks;

public class Todo extends Task{
public Todo(String content) {
super(content);
}

@Override
public String toString() {
return String.format("[T]%s", super.toString());
}
}
12 changes: 12 additions & 0 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ Hello from
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

How may I assist you?
Your current task list is empty
This task has been added as requested:
[T][ ] borrow book
You now have 1 item(s) in your list
This task has been added as requested:
[D][ ] return book (by: sunday)
You now have 2 item(s) in your list
This task has been added as requested:
[E][ ] project meeting (at: Mon 2-4pm)
You now have 3 item(s) in your list
Till we meet again
5 changes: 5 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
list
todo borrow book
deadline return book /by sunday
event project meeting /at Mon 2-4pm
bye