Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a8435c7
Level-0
Jan 31, 2025
1f4bfd9
Revert "Level-0"
Feb 7, 2025
0144f1c
Reapply "Level-0"
Feb 7, 2025
e3bd341
Enable ability to echo user's input, exit when it is bye
Feb 7, 2025
7ce0ae2
Enable the ability to store user's inputs and display them when reque…
Feb 7, 2025
0643a10
Add functions to mark and unmark tasks, while adopting a Task class t…
Feb 7, 2025
9ac4899
Optimise the way of getting input and check if the code aligns with c…
Feb 7, 2025
dd8334e
Using inheritance to support tracking 3 types of tasks: Todo, Deadlin…
Feb 14, 2025
cb07f89
Added some exceptions for dealing with errors,
Feb 14, 2025
6771044
Using ArrayList<Task> instead of an array to store tasks and turned T…
Feb 21, 2025
1eea51f
Enabled deleting tasks from the list by task index
Feb 21, 2025
02b0f40
Replaced taskCounter with taskList.size() and utilised taskList.getLa…
Mar 6, 2025
4f3ad6c
Created a new class Storage to deal with loading and saving tasks in …
Mar 6, 2025
9be6807
Made amendments in parseTaskFromString() so that there is no reassign…
Mar 6, 2025
9902379
Merge branch 'branch-Level-6'
Mar 6, 2025
217a2dd
Merge branch 'branch-Level-7'
Mar 6, 2025
5d4692d
Added loadTasks() and saveTasks() into main() to complete the task sa…
Mar 6, 2025
bd41e9f
Fixed the issue of displaying wrong no. of tasks in deleteTask()
Mar 6, 2025
a8c554c
Implemented a new class TaskList to contain the task list in Elyk and…
Mar 14, 2025
934cd37
Implemented class Ui but yet to incorporate its methods in other classes
Mar 14, 2025
27f12a9
Completed implementing all new classes for OOP and modified the logic…
Mar 14, 2025
ef12c47
Added "find" command case and method to extract keyword in Parser class
Mar 14, 2025
bc5e903
Updated Ui and TaskList classes to find and display matching tasks ac…
Mar 14, 2025
21a639f
Updated main logic in Elyk to support finding tasks by a keyword
Mar 14, 2025
3dc8f6a
Added JavaDoc comments to the Ui class and all of its methods
Mar 14, 2025
f5a0f9d
Added JavaDoc comments to 3 more classes and all of their non-private…
Mar 14, 2025
03f4d46
Completed the remaining JavaDoc comments for all classes and methods
Mar 14, 2025
071a94a
Merge pull request #1 from paklongchiu/branch-Level-9
paklongchiu Mar 14, 2025
620b83e
Merge branch 'master' into branch-A-JavaDoc
Mar 14, 2025
1c329ea
Merge pull request #2 from paklongchiu/branch-A-JavaDoc
paklongchiu Mar 14, 2025
9cc84c0
Explained the 9 main features of Elyk in UG
Mar 14, 2025
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# Elyk project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 17, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 17** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
1. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
1. After that, locate the `src/main/java/Elyk.java` file, right-click it, and choose `Run Elyk.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke User Guide
# Elyk User Guide

// Update the title above to match the actual product name

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

protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

110 changes: 110 additions & 0 deletions src/main/java/Elyk.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import java.util.Scanner;

public class Elyk {
public static int taskCounter = 0;
public static int taskNum = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The naming of these variables might suggest that they are the same. Maybe you can consider renaming them to make them clearer and more distinct.

public static String input = "";
public static String description = "";
public static String from = "";
public static String to = "";
public static String by = "";
public static Task[] taskList = new Task[100];
public static Scanner command = new Scanner(System.in);

public static void main(String[] args) {
greet();
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 job on the abstraction of code to make it neater!


while (true) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of while(true), maybe you can consider using this instead:

do {
// code to run
}
while (!input.equal("bye"));

updateInput();
switch (input) {
case "bye":
sayBye();
System.exit(0);
case "list":
printTask();
break;
case "mark":
markTaskDone(taskNum);
break;
case "unmark":
markTaskNotDone(taskNum);
break;
case "todo":
taskList[taskCounter++] = new Todo(description);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might be more readable by separating the increment to the next line instead of combining it in the same line

inputTask();
break;
case "deadline":
taskList[taskCounter++] = new Deadline(description, by);
inputTask();
break;
case "event":
taskList[taskCounter++] = new Event(description, from, to);
inputTask();
break;
default:
}
}
}

public static void greet() {
String greet = "Hello! I'm Elyk\n" +
"What can I do for you?\n";
System.out.println(greet);
}

public static void sayBye() {
String bye = "Bye. Hope to see you again soon!";
System.out.println(bye);
}

public static void updateInput() {
input = command.nextLine();
if (input.startsWith("mark") || input.startsWith("unmark")) {
String[] words = input.split(" ");
input = words[0];
taskNum = Integer.parseInt(words[1]);
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 could potentially have issues if the second word is not a number. Attempting to parseInt a String may crash the program/cause an exception

} else if (input.startsWith("todo")) {
description = input.substring(5);
input = "todo";
} else if (input.startsWith("deadline")) {
int byPos = input.indexOf("/by");
by = input.substring(byPos + 4);
description = input.substring(9, byPos - 1);
input = "deadline";
} else if (input.startsWith("event")) {
int fromPos = input.indexOf("/from");
int toPos = input.indexOf("/to");
to = input.substring(toPos + 4);
from = input.substring(fromPos + 6, toPos - 1);
description = input.substring(6, fromPos - 1);
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 you can refactor the magic literals throughout your code to make it easier to understand

input = "event";
}
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 you can include the final else statement for error detection

}

public static void markTaskDone(int taskNum) {
taskList[taskNum - 1].markAsDone();
System.out.println("Nice! I've marked this task as done:");
System.out.println(" " + taskList[taskNum - 1]);
}

public static void markTaskNotDone(int taskNum) {
taskList[taskNum - 1].markAsNotDone();
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 seems like a redundant method, is it possible to call a single method without chaining multiple methods that do the same thing?

System.out.println("OK, I've marked this task as not done yet:");
System.out.println(" " + taskList[taskNum - 1]);
}

public static void inputTask() {
System.out.println("Got it. I've added this task:");
System.out.println(" " + taskList[taskCounter - 1]);
System.out.println("Now you have " + taskCounter + " tasks in the list.");
}

public static void printTask() {
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < taskCounter; i++) {
System.out.println((i+1) + "." + taskList[i]);
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 you can standardise the use of spacing within your i+1 to make it more consistent (i + 1 instead)

}
}
}


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

protected String from;
protected String to;

public Event(String description, String from, String to) {
super(description);
this.from = from;
this.to = to;
}

@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + from + " to: " + to + ")";
}
}
26 changes: 26 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

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

public void markAsDone() {
isDone = true;
}

public void markAsNotDone() {
isDone = false;
}

@Override
public String toString() {
return "[" + getStatusIcon() + "] " + description;
}
}
11 changes: 11 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Todo extends Task {

public Todo(String description) {
super(description);
}

@Override
public String toString() {
return "[T]" + super.toString();
}
}
2 changes: 1 addition & 1 deletion text-ui-test/runtest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 (
REM no error here, errorlevel == 0

REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
java -classpath ..\bin Elyk < input.txt > ACTUAL.TXT

REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT