Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dexter Hoon] iP #68

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c606c3c
Rename main class
DextheChik3n Aug 24, 2023
e3f01fa
Add greeting and exit functions
DextheChik3n Aug 24, 2023
3afcb6b
Refactor printHorrizontalLine function
DextheChik3n Aug 31, 2023
184e708
Add echo function
DextheChik3n Aug 31, 2023
cf80b82
Add list functionality
DextheChik3n Aug 31, 2023
1afaaf1
Add Task.java class
DextheChik3n Sep 3, 2023
e331bb9
Add mark and unmark tasks feature
DextheChik3n Sep 3, 2023
951a3e6
Main.java: Fix handling exit command
DextheChik3n Sep 3, 2023
7a7066d
Update Alan.java to follow coding standard
DextheChik3n Sep 3, 2023
32601dd
Add todo, deadline and event tasks
DextheChik3n Sep 7, 2023
ff60709
Update input.txt and EXPECTED.TXT for automated testing
DextheChik3n Sep 7, 2023
3550db1
Refactor Alan class
DextheChik3n Sep 7, 2023
ae095d1
Refactor Alan.java
DextheChik3n Sep 13, 2023
31437f8
Add error handling for invalid command and todo tasks
DextheChik3n Sep 13, 2023
511f4d2
Add error handling for deadline and event invalid input formatting
DextheChik3n Sep 13, 2023
eb7f6ae
Add error handling for mark/unmark unknown tasks
DextheChik3n Sep 13, 2023
b168238
Merge branch 'branch-Level-5'
DextheChik3n Sep 13, 2023
4194ba3
Change message texts
DextheChik3n Sep 14, 2023
8365fc3
Organize classes into java packages
DextheChik3n Sep 14, 2023
44587d6
Merge branch 'branch-A-Packages'
DextheChik3n Sep 14, 2023
c7bcaaa
Refactor error exception and command handling
DextheChik3n Sep 14, 2023
17b65ef
Change Alan to store tasks in ArrayList
DextheChik3n Sep 19, 2023
1933454
Add delete function
DextheChik3n Sep 19, 2023
41ce6df
Update tasks to set and get task contents
DextheChik3n Sep 20, 2023
88bace6
Add saving task list to text file functionality
DextheChik3n Sep 20, 2023
94bcc13
Update gitignore to exclude tasks.txt
DextheChik3n Sep 20, 2023
a49e395
Add saving and loading tasks from text file
DextheChik3n Sep 20, 2023
23738a8
Merge branch 'branch-Level-6'
DextheChik3n Sep 20, 2023
3dab5c7
Merge branch 'branch-Level-7'
DextheChik3n Sep 20, 2023
425e388
Refactor read function in Alan.java
DextheChik3n Sep 20, 2023
b6ecfbe
.gitignore: add MANIFEST.MF
DextheChik3n Sep 26, 2023
eeee528
Create packages to organise java classes
DextheChik3n Sep 30, 2023
d7ccba5
Create classes to organise code
DextheChik3n Oct 1, 2023
361eb39
Implement UI Class
DextheChik3n Oct 1, 2023
4935bba
Implement TaskList class
DextheChik3n Oct 1, 2023
7f3c631
Implement Parser class
DextheChik3n Oct 2, 2023
d140956
Implement Storage class
DextheChik3n Oct 2, 2023
2d45aff
Add reading invalid task type in Storage class
DextheChik3n Oct 2, 2023
310e2b4
Add date parsing
DextheChik3n Oct 2, 2023
61e0f3c
Add find task functionality
DextheChik3n Oct 2, 2023
4c9970f
Merge pull request #1 from DextheChik3n/branch-Level-8
DextheChik3n Oct 2, 2023
51959a1
Add JavaDoc comments
DextheChik3n Oct 3, 2023
64c21f4
Merge branch 'master' into branch-Level-9
DextheChik3n Oct 3, 2023
4b5849c
Merge branch 'master' into branch-A-JavaDoc
DextheChik3n Oct 3, 2023
4bac978
Merge pull request #2 from DextheChik3n/branch-Level-9
DextheChik3n Oct 3, 2023
ef54d91
Merge branch 'master' into branch-A-JavaDoc
DextheChik3n Oct 3, 2023
c63d05e
Merge pull request #3 from DextheChik3n/branch-A-JavaDoc
DextheChik3n Oct 3, 2023
7efbd2b
Update README.md
DextheChik3n Oct 3, 2023
4a0b8b8
Remove Command Summary section from README.md
DextheChik3n Oct 3, 2023
151f23c
Refactor magic strings
DextheChik3n Oct 3, 2023
1f42faa
Add error handling for empty user input
DextheChik3n Oct 3, 2023
efc4ab2
Add handling of printing empty lists
DextheChik3n Oct 3, 2023
036f277
Add error handling for mark, unmark and delete command
DextheChik3n Oct 3, 2023
f67cbbf
Remove unused imports
DextheChik3n Oct 3, 2023
6cc4255
Update README.md
DextheChik3n Oct 3, 2023
e4f770e
Fix storing empty TaskList to text file
DextheChik3n Oct 3, 2023
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
45 changes: 25 additions & 20 deletions src/main/java/Alan.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class Alan {

public static void printGreet() {
public static void printGreetingMessage() {
printHorizontalLine();
String man = " @/\n" +
"/| \n" +
Expand All @@ -14,7 +14,7 @@ public static void printGreet() {
printHorizontalLine();
}

public static void printExit() {
public static void printExitMessage() {
System.out.println("Bye. Hope to see you again soon!");
}

Expand All @@ -23,10 +23,10 @@ public static void printHorizontalLine() {
}

public static void main(String[] args) {
Copy link
Member

Choose a reason for hiding this comment

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

Try to avoid long methods. You can try to extract part of the code into other methods.

Copy link
Author

Choose a reason for hiding this comment

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

Alright sure I can try to break the long method into smaller methods to handle each of the commands which can make it easier to debug and organise my code

Task[] taskList = new Task[101];
int currentTaskListIndex = 1;
Task[] tasks = new Task[101];
int currentTasksIndex = 1;

printGreet();
printGreetingMessage();
DextheChik3n marked this conversation as resolved.
Show resolved Hide resolved

String userInput = " ";
DextheChik3n marked this conversation as resolved.
Show resolved Hide resolved
Scanner in = new Scanner(System.in);
Expand All @@ -37,35 +37,40 @@ public static void main(String[] args) {
userInput = in.nextLine();

printHorizontalLine();

if (userInput.equals("bye")) {
printExit();
} else if (userInput.equals("list")) { //print the tasks in the lists
printExitMessage();
} else if (userInput.equals("list")) {
//print the tasks in the lists
System.out.println("Here are the tasks in your list:");
for (int i = 1; i < currentTaskListIndex; i++) {
System.out.println((i) + ". [" + taskList[i].getStatusIcon() + "] " + taskList[i].getDescription());
for (int i = 1; i < currentTasksIndex; i++) {
System.out.println((i) + ". [" + tasks[i].getStatusIcon() + "] " + tasks[i].getDescription());
}
} else if (userInput.startsWith("mark")) { //mark tasks as done
} else if (userInput.startsWith("mark")) {
//mark tasks as done
String[] words = userInput.split(" ");

taskList[Integer.parseInt(words[1])].setDone(true);
tasks[Integer.parseInt(words[1])].setDone(true);

System.out.println("Alright! I've marked this task as done:");
System.out.println("\t[" + taskList[Integer.parseInt(words[1])].getStatusIcon() + "] " +
taskList[Integer.parseInt(words[1])].getDescription());
System.out.println("\t[" + tasks[Integer.parseInt(words[1])].getStatusIcon() + "] " +
tasks[Integer.parseInt(words[1])].getDescription());
Copy link
Member

Choose a reason for hiding this comment

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

Try to avoid complicated expressions.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah very true... I will follow what someone else suggested by using more variables to simplify the statement


} else if (userInput.startsWith("unmark")) { //unmark tasks as undone
} else if (userInput.startsWith("unmark")) {
//unmark tasks as undone
String[] words = userInput.split(" ");

taskList[Integer.parseInt(words[1])].setDone(false);
tasks[Integer.parseInt(words[1])].setDone(false);

Choose a reason for hiding this comment

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

Could you rename this line as a variable, seeing as you use it later in your code?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion... I think it could be helpful to do this as it can make my code neater :D


System.out.println("Ok, I've marked this task as not done yet:");
System.out.println("\t[" + taskList[Integer.parseInt(words[1])].getStatusIcon() + "] " +
taskList[Integer.parseInt(words[1])].getDescription());
System.out.println("\t[" + tasks[Integer.parseInt(words[1])].getStatusIcon() + "] " +

Choose a reason for hiding this comment

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

Maybe making some variables statement could make this less verbose

Copy link
Author

Choose a reason for hiding this comment

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

I agree... will probably do that since it does look very complex and hard to understand what is going on

tasks[Integer.parseInt(words[1])].getDescription());

} else { //add a new task to the list
} else {
//add a new task to the list
Task task = new Task(userInput);
taskList[currentTaskListIndex] = task;
currentTaskListIndex++;
tasks[currentTasksIndex] = task;
currentTasksIndex++;
System.out.println("added: " + userInput);
}

Expand Down