Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
7b4399b
Duke.java: Added formatAnswer method for formatting Duke's outputs
juayhee Jan 19, 2022
20727de
Duke.java: Updated main(): Duke will now echo all commands (except ex…
juayhee Jan 19, 2022
97f6a4d
Duke.java: Fixed javadocs formatting
juayhee Jan 19, 2022
ed4337c
Command.java: Added Command class
juayhee Jan 19, 2022
cdbfc4d
* Abstracted commands - Duke.main() now only calls a CommandFactory t…
juayhee Jan 19, 2022
8723e8a
Formatting
juayhee Jan 20, 2022
d966605
TaskManager.java: Added TaskManager, to manage a todo list for the user.
juayhee Jan 20, 2022
e873f1c
Updated scope of abstract method in Command to public
juayhee Jan 20, 2022
a0644ae
Added AddTaskCommand and ListCommand
juayhee Jan 20, 2022
d0aec24
TaskManager.java: Changed taskList to use ArrayList instead of array …
juayhee Jan 20, 2022
1d0ed92
AddTaskCommand.java:
juayhee Jan 20, 2022
7fd4062
ListCommand.java: Added formatted taskList printing.
juayhee Jan 20, 2022
2f8c2dc
Added support for marking tasks as done/undone
juayhee Jan 20, 2022
bfabfc4
Revert "Added support for marking tasks as done/undone"
juayhee Jan 20, 2022
d0c7e0d
Revert "Revert "Added support for marking tasks as done/undone""
juayhee Jan 20, 2022
61656f5
Added Mark and UnmarkCommand, for keeping track of completion status …
juayhee Jan 20, 2022
57956c4
Formatting update
juayhee Jan 20, 2022
3cf225d
Mark/Unmark formatting update
juayhee Jan 20, 2022
248b305
Task inheritance
juayhee Jan 20, 2022
d82d80f
Added 3 types of tasks
juayhee Jan 20, 2022
b101bbd
Task.java: Updated tto become general parent class for the different …
juayhee Jan 20, 2022
8287dd3
CommandFactory.java: Added factory methods for 3 new tasks (Event, De…
juayhee Jan 20, 2022
3db0f4a
AddTaskCommand.java: Now adds the appropriate task to the TaskManager…
juayhee Jan 20, 2022
cfdfd2a
DeadlineTask: Formatting
juayhee Jan 20, 2022
2af976f
DeadlineTask.java: Comment update
juayhee Jan 20, 2022
4db97ca
EventTask.java: Completed functionality
juayhee Jan 20, 2022
47f5f59
Duke lines
juayhee Jan 20, 2022
966526c
Semi-automated testing
juayhee Jan 20, 2022
30de0fd
Exception handling:
juayhee Jan 20, 2022
5beda05
Added delete functionality for deleting tasks from the task list
juayhee Jan 20, 2022
d937b63
test commit
juayhee Feb 1, 2022
be5f127
Delete README.md copy
juayhee Feb 1, 2022
69a5f11
Update EXPECTED.TXT
juayhee Feb 2, 2022
74a2c76
Fix Issue #1
juayhee Feb 2, 2022
5a8e292
Duke.java: Add tasklist.txt file on init functionality
juayhee Feb 2, 2022
f69c29e
Update gitignore
juayhee Feb 2, 2022
7ad1b73
Merge branch 'master' of https://github.com/juayhee/ip
juayhee Feb 3, 2022
44d9e53
Update Duke.java
juayhee Feb 3, 2022
fb0dcd4
Update Duke.java
juayhee Feb 3, 2022
27ab11c
Update AddTaskCommand.java
juayhee Feb 3, 2022
c5b41cb
Merge branch 'master' into branch-Level-7
juayhee Feb 3, 2022
5d651b4
Update Task.java
juayhee Feb 3, 2022
3d44bb3
Update AddTaskCommand.java
juayhee Feb 3, 2022
bc740e1
Refactor the way Duke updates tasklist.txt
juayhee Feb 3, 2022
b2a7783
Add task saving ability
juayhee Feb 3, 2022
5d6fe8d
Added Duke functionality
juayhee Feb 4, 2022
a4f8f9c
Fix reader mistake in TaskManager.java
juayhee Feb 4, 2022
f15ab5d
Change file writing process
juayhee Feb 4, 2022
bbeb23c
TaskManager.java: Delete unused code
juayhee Feb 4, 2022
0956cbd
Change DeadlineTask.java
juayhee Feb 4, 2022
c083eea
Change date display
juayhee Feb 4, 2022
2ef087b
Merge branch 'branch-Level-8'
juayhee Feb 4, 2022
759928f
Add Ui to manage user interactions
juayhee Feb 4, 2022
3840260
ByeCommand.java: Move system print to Ui
juayhee Feb 4, 2022
80f7830
ListCommand.java: Move system print to Ui
juayhee Feb 4, 2022
e26c321
Ui.java: Improve output format of printAddTask()
juayhee Feb 4, 2022
b234b5f
MarkCommand.java: Move system print to ui
juayhee Feb 6, 2022
db98dc6
MarkCommand.java: Deprecate unused code
juayhee Feb 6, 2022
0bed81c
Duke.java: Move introduction print to ui
juayhee Feb 6, 2022
2361f53
DeleteCommand.java: Move delete confirmation print to ui
juayhee Feb 6, 2022
52bda78
UnmarkCommand.java: Move delete confirmation print to ui
juayhee Feb 6, 2022
85b1867
Delete a bunch of deprecated code
juayhee Feb 6, 2022
73ac0f4
Delete EchoCommand.java
juayhee Feb 6, 2022
c183af8
Duke.java: Delete deprecated formatting code
juayhee Feb 6, 2022
1d1dc1d
Rename TaskManager to TaskList
juayhee Feb 6, 2022
8096783
Replace CommandFactory with Parser
juayhee Feb 6, 2022
89bc29c
Refactor code
juayhee Feb 6, 2022
e31eb90
Move all files into package: duke
juayhee Feb 6, 2022
d786f16
Update gitignore
juayhee Feb 6, 2022
f7f91d0
no message
juayhee Feb 6, 2022
c19fdea
no message
juayhee Feb 6, 2022
a2f29b8
no message
juayhee Feb 6, 2022
1007b0c
no message
juayhee Feb 6, 2022
a5ce67d
Duke.java: Fix error where duke tries to load the tasklist before the…
juayhee Feb 6, 2022
7e7952b
Add ParserTest to test the parser for Duke
juayhee Feb 7, 2022
8019fe1
Update ParserTest with more tests
juayhee Feb 7, 2022
4d7e4e8
Add TaskTest.java to test Task.java of Duke
juayhee Feb 7, 2022
f804901
no message
juayhee Feb 7, 2022
4510ca1
Add javadocs header comments
juayhee Feb 7, 2022
8c54d0b
Formatting
juayhee Feb 7, 2022
1f545cd
Add search function for tasks
juayhee Feb 7, 2022
f373b0b
Merge branch 'branch-A-CodingStandard'
juayhee Feb 7, 2022
258aec9
Merge branch 'branch-A-JavaDoc'
juayhee Feb 7, 2022
684b1ed
Fix additional whitespaces during printing of list
juayhee Feb 7, 2022
20443e1
Merge remote-tracking branch 'origin/add-gradle-support'
juayhee Feb 9, 2022
f7cdf58
Gradle integration
juayhee Feb 9, 2022
2b225c7
Add GUI classes
juayhee Feb 9, 2022
ad9f2d3
Add GUI mockup
juayhee Feb 9, 2022
0921ff0
Add DialogBox stuff
juayhee Feb 9, 2022
80c0521
Edit GUI to make Duke display text on one side and the user display t…
juayhee Feb 14, 2022
6ade60a
Refactor userText variable
juayhee Feb 14, 2022
baf32d6
Link DukeGUI inputs to Duke
juayhee Feb 14, 2022
1944558
DukeGUI now prints output correctly
juayhee Feb 14, 2022
00d3761
Fix output formatting
juayhee Feb 14, 2022
2263420
Update Gradle build file
juayhee Feb 18, 2022
9988e6f
Add assertions
juayhee Feb 18, 2022
31c8ffb
Delete dead code
juayhee Feb 18, 2022
256c1e4
Merge pull request #3 from juayhee/branch-A-CodeQuality
juayhee Feb 18, 2022
46aa19e
Merge branch 'master' into branch-A-Assertions
juayhee Feb 18, 2022
5006aec
Merge pull request #4 from juayhee/branch-A-Assertions
juayhee Feb 18, 2022
a59d26f
Add command aliases to Duke
juayhee Feb 18, 2022
874de1e
Add product website, fix bugs
juayhee Feb 18, 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
47 changes: 47 additions & 0 deletions src/main/java/AddTaskCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Generates the correct type of task and adds it to the task list
*/

public class AddTaskCommand extends Command {
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 believe class names should be nouns written in camelCasing according to coding standards.


private String input; // Details of the task
private String type; // Type of task

public AddTaskCommand(String input, String type) {
this.input = input;
this.type = type;
}

/**
* Formats the echo for the task that was added to the user as confirmation
* @return Formatted echo
*/
private String formatOutput(Task newTask) {
String response = "added: " + newTask.toString();
String formattedString = Duke.indent(response, 1);
String finalFormatted = Duke.formatLines(formattedString);

return finalFormatted;
}

@Override
public void execute() {
Task newTask;
if (this.type.equals("todo")) {
newTask = new TodoTask(this.input);
} else if (this.type.equals("deadline")) {
newTask = new DeadlineTask(this.input);
} else if (this.type.equals("event")) {
newTask = new EventTask(this.input);
} else {
newTask = null;
}

// Adding task to TaskManager
TaskManager.taskList.add(newTask);

// System prints
String output = formatOutput(newTask);
System.out.println(output);
}
}
22 changes: 22 additions & 0 deletions src/main/java/ByeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Prints bye message, terminating command for Duke.main()
*/
public class ByeCommand extends Command {

final String EXIT = "Duke terminated";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of naming standards


private String formatOutput() {
String formattedBye = Duke.indent(EXIT, 1);
String finalFormatted = Duke.formatLines(formattedBye);

return finalFormatted;
}
@Override
public void execute() {
// Console prints
String output = formatOutput();

System.out.println(output);

}
}
3 changes: 3 additions & 0 deletions src/main/java/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public abstract class Command {
public abstract void execute();
}
62 changes: 62 additions & 0 deletions src/main/java/CommandFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Decides which type of command to generate given user input
*/
public class CommandFactory {

/**
* Extracts the command portion of the input provided by the user (usually first word)
*
* @param input Input from the user
* @return One word string
*/
private String isolateCommand(String input) {
int whiteSpaceIndex = input.indexOf(" "); // Index of first whitespace
if (whiteSpaceIndex == -1) { // If the input string has no whitespaces (i.e. one word)
return input;
}
return input.substring(0, whiteSpaceIndex);
}

/**
* Extracts the command parameters portion of the input provided by the user (stuff after first word)
*
* @param input Input from the user
* @return Multiple-word string
*/
private String isolateParameters(String input) {
int whiteSpaceIndex = input.indexOf(" "); // Index of first whitespace
if (whiteSpaceIndex == -1) { // If the input string has no whitespaces (i.e. one word)
return null;
}
return input.substring(whiteSpaceIndex + 1); // Return the rest of the word, starting from after whitespace
}

/**
* Generates the appropriate command type given the input
*
* @param input Input from the user
* @return Value of parent type Command
*/
public Command makeCommand(String input) {
String commandWord = isolateCommand(input);
String commandParameters = isolateParameters(input);

if (commandWord.equals("bye")) {
return new ByeCommand();
} else if (commandWord.equals("list")) {
return new ListCommand();
} else if (commandWord.equals("mark")) {
return new MarkCommand(commandParameters);
} else if (commandWord.equals("unmark")) {
return new UnmarkCommand(commandParameters);
} else if (commandWord.equals("todo")) {
return new AddTaskCommand(commandParameters, "todo");
} else if (commandWord.equals("deadline")) {
return new AddTaskCommand(commandParameters, "deadline");
} else if (commandWord.equals("event")) {
return new AddTaskCommand(commandParameters, "event");
} else {
return null;
}
}
}
52 changes: 52 additions & 0 deletions src/main/java/DeadlineTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
public class DeadlineTask extends Task {
public DeadlineTask(String input) {
super(input);
this.type = "deadline";
this.updateDescription();
}

/**
* Format DeadlineTask description into display format for Duke
*/
private void updateDescription() {
this.description += this.getInfo();
this.description += "(by: ";
this.description += this.getDate();
this.description += ")";
Comment on lines +18 to +
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 like your proper use of method naming standards(descriptive, camelCased verbs)

}

/**
* Find the index from which datetime information starts
*
* @return Integer index
*/
private int findDeadlineIndex() {
int index = this.input.indexOf("/by "); // "/" as delimiting character for events
return index;
}

/**
* Gets the task information
*
* @return Task information
*/
private String getInfo() {
int index = this.findDeadlineIndex();
String info = this.input.substring(0, index);

return info;
}

/**
* Gets the deadline date
*
* @return Deadline date string
*/
private String getDate() {
int index = this.findDeadlineIndex() + 4;
String date = this.input.substring(index);

return date;
}

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

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
// Constant strings
final String INTRO = "Duke initialised";

// Init
Scanner sc = new Scanner(System.in);

// Printing Duke's intro
String formattedIntroText = Duke.indent(INTRO, 1);
String formattedIntro = Duke.formatLines(formattedIntroText);
System.out.println(formattedIntro);

// Reading and processing inputs
String nextLine = sc.nextLine();
CommandFactory commandFactory = new CommandFactory();
while (true) {
Command nextCommand = commandFactory.makeCommand(nextLine); // Creating the appropriate command
nextCommand.execute();

if (nextCommand instanceof ByeCommand) { // Check for exit command
break;
}
nextLine = sc.nextLine(); // Update nextLine variable with next input
}

}

/**
* Checks if input is "bye"
*/
private boolean isBye(String input) {

return (input.equals("bye"));
}

/**
* Formats the given input between lines
* @param input Formatted input with proper indents and newlines.
*/
public static String formatLines(String input) {
String output = "";
output += Duke.line();
output += input;
output += "\n" + Duke.line();

return output;
}

/**
* Provides a formatting line for Duke's responses
*
* @return A formatted line
*/
public static String line() {
String line = "\t____________________________________________________________\n";
return line;
}

/**
* Formats a single line with a new line
*
* @param input Input string
* @return String with newline
*/
public static String newLine(String input) {
String output = input + "\n";
return output;
}

/**
* Formats a single line with the specified number of indentations
*
* @param input Input string
* @param indents Number of indents to add
* @return String with specified number of indents
*/
public static String indent(String input, int indents) {
String indent = "";
String output = "";

// Adding the appropriate number of indents
for (int i = 0; i < indents; i++) {
indent += "\t";
}

// Forming the final string
output = indent + input;

return output;


}
}
25 changes: 25 additions & 0 deletions src/main/java/EchoCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Repeats input to user
*/
public class EchoCommand extends Command {

private String input;

public EchoCommand (String input) {
this.input = input;
}

public String formatOutput (String input) {
String formattedInput = Duke.indent(input, 1);
String finalFormatted = Duke.formatLines(formattedInput);

return finalFormatted;
}
@Override
public void execute() {

// Console prints
String output = formatOutput(input);
System.out.println(output);
}
}
51 changes: 51 additions & 0 deletions src/main/java/EventTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
public class EventTask extends Task {
public EventTask(String input) {
super(input);
this.type = "event";
this.updateDescription();
}

/**
* Format EventTask description into display format for Duke
*/
private void updateDescription() {
this.description += this.getInfo();
this.description += "(at: ";
this.description += this.getDate();
this.description += ")";
}

/**
* Find the index from which datetime information starts
* @return Integer index
*/
private int findEventIndex() {
int index = this.input.indexOf("/at "); // "/at" as delimiting character for events
return index;
}

/**
* Gets the task information
* @return Task information
*/
private String getInfo() {
int index = this.findEventIndex();
String info = this.input.substring(0, index);

return info;
}

/**
* Gets the deadline date
* @return Deadline date string
*/
private String getDate() {
int index = this.findEventIndex() + 4; // Offset of the string "/at "
String date = this.input.substring(index);

return date;
}

}


Loading