Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d3163e8
Added the driver function to take in user input.
jared98lyj Feb 4, 2021
d4a6722
Level 2
jared98lyj Feb 4, 2021
fe3ca81
Updated to level 3.
jared98lyj Feb 5, 2021
5039c1a
Level-4
jared98lyj Feb 5, 2021
da14f03
Level-5
jared98lyj Feb 5, 2021
0de7bcb
Level-6
jared98lyj Feb 6, 2021
5da5f47
Renamed to Duke.java
jared98lyj Feb 6, 2021
77d1af0
Level-7
jared98lyj Feb 7, 2021
18fefbf
Level-8
jared98lyj Feb 10, 2021
c8a2318
A-J-Unit
jared98lyj Feb 11, 2021
1304374
Level-9
jared98lyj Feb 13, 2021
4f24e1a
A-MoreOOP
jared98lyj Feb 14, 2021
1840dd9
Add JUnit Tests
jared98lyj Feb 14, 2021
0ea2605
Made the classes more OOP-like.
jared98lyj Feb 14, 2021
32edbd5
Level-10
jared98lyj Feb 15, 2021
14600d2
Added important assertions throughout the code. Some of them include …
jared98lyj Feb 15, 2021
03647c1
Improved abstration in the Duke.java, erasing direct array/list acces…
jared98lyj Feb 15, 2021
e7ef799
Improved the find function to be more flexible, giving the user the o…
jared98lyj Feb 15, 2021
e1e5628
Built a basic GUI for interaction betwen user and bot.
jared98lyj Feb 16, 2021
51aa8fe
Added a simple user guide with some usage examples and corresponding …
jared98lyj Feb 16, 2021
bf88b10
Added java doc comments for most methods, less the getter and setter …
jared98lyj Feb 19, 2021
0f29c67
Improved code quality by ensuring similar levels of abstraction in a …
jared98lyj Feb 19, 2021
f81b02a
Refactored CLI version of Duke.java.
jared98lyj Feb 19, 2021
507b9d7
Improved consistency of String representation and formatting.
jared98lyj Feb 19, 2021
677fc36
Added input and expected text to the files. Debugged some of the inco…
jared98lyj Feb 19, 2021
9949574
Fixed launching issues with duke.jar file.
jared98lyj Feb 19, 2021
1b8b269
Made final changes to the readMe file and added a background image.
jared98lyj Feb 19, 2021
e874003
Update README.md
jared98lyj Feb 19, 2021
95b3b38
Delete README.md
jared98lyj Feb 19, 2021
d6ece15
Updated minor changes to UI class.
jared98lyj Feb 19, 2021
7207a74
Set theme jekyll-theme-slate
jared98lyj Feb 20, 2021
518584e
Commtting the Ui.png file to docs directory
jared98lyj Feb 20, 2021
b4d202a
Revert "Commtting the Ui.png file to docs directory"
jared98lyj Feb 20, 2021
64f4838
Merge branch 'master' of https://github.com/jared98lyj/ip
jared98lyj Feb 20, 2021
c110de9
Commiting the Ui.png to docs directory
jared98lyj Feb 20, 2021
23b0d4c
no message
jared98lyj Feb 20, 2021
a8522c6
Renamed image file to Ui.png
jared98lyj Feb 21, 2021
7af6082
Renamed to Ui.png
jared98lyj Feb 21, 2021
b07b0a0
Update README.md
jared98lyj Mar 7, 2021
5f828d2
Update README.md
jared98lyj Mar 7, 2021
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
13 changes: 9 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# User Guide

JDK 11
## Features

### Feature 1
Description of feature.
Bot that takes in a list of actions to do and stores it in a list. Tasks that are
done are marked as done.

## Usage

### `Keyword` - Describe action

Describe action and its outcome.

Basic todo list.
Example of usage:

`keyword (optional arguments)`
`Read book`

Expected outcome:

Retrieving the list by typing the string list as input will give:
Here are the tasks in your list:
1.[] Read book

`outcome`
23 changes: 23 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class Deadline extends Task {

Deadline(String description) {
super(description);
}

Deadline(String description, String eventDate) {
super(description, eventDate);
}

@Override
public String getTaskType() {
return "D";
}

@Override
public String toString() {
return String.format("[%s][%s] %s(by:%s)", this.getTaskType(),
this.getStatusIcon(), this.getDescription(), this.getEventDate());
}


}
137 changes: 131 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,135 @@
import java.util.ArrayList;
import java.util.Scanner;

/**
* Driver class that takes in input and performs certain functions based on input.
*/
public class Duke {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this class is rather long, perhaps you could consider abstracting the methods out?


protected static ArrayList<Task> taskList = new ArrayList<>();

/**
* Main class to take in user input.
* @param args Filler
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 a more meaningful name for @param could be possibly replaced here

*/
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
Scanner sc = new Scanner(System.in);

String command = "Hello";

while (!command.equalsIgnoreCase("bye")) {
if (command.equals("Hello")) {
System.out.println("Hello! I'm Duke");
System.out.println("What can I do for you?");
} else if (command.equals("list")) {
enumerateTasks();
} else if (command.startsWith("done")) {
String[] delString = command.split("\\s+");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

delString is not a very intuitive variable name, maybe you could make it more specific?

markAsDone(Integer.parseInt(delString[1]));
} else if (command.startsWith("todo")) {
try {
Todo currentTask = new Todo(command.substring(5));
addToTasks(currentTask);
logTask(currentTask);
} catch (StringIndexOutOfBoundsException indexError) {
System.out.println("☹ OOPS!!! The description of a todo cannot be empty.");
}

} else if (command.startsWith("event")) {
try {
String[] splitString = command.split("/at");
String eventDesc = splitString[0];
String eventDate = splitString[1];
Event currentTask = new Event(eventDesc.substring(6), eventDate);
addToTasks(currentTask);
logTask(currentTask);
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException indexError) {
System.out.println("☹ OOPS!!! The description of an event cannot " +
"be empty.");
}
} else if (command.startsWith("deadline")) {
try {
String[] splitString = command.split("/by");
String eventDesc = splitString[0];
String eventDate = splitString[1];
Deadline currentTask = new Deadline(eventDesc.substring(9), eventDate);
addToTasks(currentTask);
logTask(currentTask);
} catch (ArrayIndexOutOfBoundsException | StringIndexOutOfBoundsException indexError) {
System.out.println("☹ OOPS!!! The description of a deadline " +
"cannot be empty.");
}
} else if (command.startsWith("delete")) {
String[] splitString = command.split("\\s+");
removeTask(Integer.parseInt(splitString[1]));
} else {
// Command is not recognized
System.out.println("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
}

command = sc.nextLine();

}

System.out.println("Bye. Hope to see you again soon!");

}

/**
* Prints the statements showing this task has been added to list.
* @param currentTask Current task.
*/
protected static void logTask(Task currentTask) {
System.out.println("Got it. I've added this task:");
System.out.println(currentTask);
System.out.println(String.format("Now you have %d tasks in the list"
, taskList.size()));
}

/**
* Adds current task to list of tasks.
* @param currentTask Current task.
*/
protected static void addToTasks(Task currentTask) {
taskList.add(currentTask);
}

/**
* Enumerates all tasks in the lis using 1-based indexing.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor typo for "list"

*/
protected static void enumerateTasks() {
System.out.println("Here are the tasks in your list:");
int counter = 1;
for (Task eachTask : taskList) {
System.out.println(String.format("%d. %s", counter, eachTask));
counter++;
}
}

/**
* Marks task as done based on 1-based indexing.
* @param index Given index of task
*/
protected static void markAsDone(int index) {
// Retrieving task
Task givenTask = taskList.get(index - 1);
givenTask.markAsDone();
System.out.println("Nice! I've marked this task as done:");
System.out.println(String.format(" [%s][%s] %s",
givenTask.getTaskType(), givenTask.getStatusIcon(),
givenTask.getDescription()));
}

/**
* Removes respective task in the list (1-based indexing).
* @param index Index of task to remove
*/
protected static void removeTask(int index) {
Task removedTask = taskList.remove(index - 1);
System.out.println("Noted. I've removed this task:");
System.out.println(" " + removedTask);
System.out.println(String.format("Now you have %d tasks in your list.",
taskList.size()));
}

}
35 changes: 35 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
public class Event extends Task {

/**
* Main Constructor.
* @param description Description of given task.
*/
Event(String description) {
super(description);
}

/**
* Overriden constructor to account for deadline and events that have timestamps.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not too sure if "Overriden" is the appropriate term here. I think "Overloaded constructor" may be more appropriate.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i think the term you meant to use might be "overloaded" instead

* @param description Description of given task.
* @param eventDate Timestamp of given task.
*/
Event(String description, String eventDate) {
super(description, eventDate);
}

/**
* Retrieving the given task type.
* @return String giving the task type, in this case E.
*/
@Override
public String getTaskType() {
return "E";
}

@Override
public String toString() {
return String.format("[%s][%s] %s(at:%s)", this.getTaskType(),
this.getStatusIcon(), this.getDescription(), this.getEventDate());
}

}
55 changes: 55 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
public class Task {

protected String description;
protected String eventDate;
protected boolean isDone;

enum Level {
low,
average,
high
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think that constants in enum should be in all uppercase, eg "LOW", "AVERAGE" and "HIGH"

}


/**
* Main constructor that accepts a description of the task, and by default
* assigns a false value to the undone task.
* @param description Description of task
*/
public Task(String description) {
this.description = description;
this.isDone = false;
this.eventDate = "";
}

/**
* Overriden method to mark a task 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.

Did you mean "Overloaded" here as well? I've noticed it in a few other places. Otherwise, as the other reviewer mentioned, overridden methods should tagged with "@OverRide"

* @param description Description of method
* @param eventDate Boolean flag indicating whether task is done
*/
public Task(String description, String eventDate) {
Copy link
Copy Markdown

@justgnohUG justgnohUG Feb 6, 2021

Choose a reason for hiding this comment

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

Might be a good idea to add "@OverRide" tag if this method is truly overriden

this.description = description;
this.eventDate = eventDate;
}

public String getTaskType() {
return "";
};

public String getStatusIcon() {
return isDone ? "X" : "";
}

public String getDescription() {
return this.description;
}

public String getEventDate() {
return this.eventDate;
}

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

}
25 changes: 25 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class Todo extends Task {

/**
* Main constructor.
* @param description Description of task.
*/
Todo(String description) {
super(description);
}

/**
* Getter method that retrieves the type of the task.
* @return String representing task type.
*/
@Override
public String getTaskType() {
return "T";
}

@Override
public String toString() {
return String.format("[%s][%s] %s ", this.getTaskType(),
this.getStatusIcon(), this.getDescription());
}
}