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

[Singh Abdullah Alexander] iP #519

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
df365b5
Completed Level-1
alexandermula Aug 25, 2022
1346cd5
added list
alexandermula Aug 25, 2022
35f557b
Added mark as done
alexandermula Aug 25, 2022
1427298
ToDos, Events and Deadlines
alexandermula Aug 25, 2022
924806e
Text testing
alexandermula Aug 25, 2022
7a099dd
error handling
alexandermula Aug 25, 2022
23228eb
Implemented delete
alexandermula Aug 25, 2022
79c8c7b
Added file read function (to refine save function later)
alexandermula Sep 1, 2022
a9e73ff
Store dates as date object
alexandermula Sep 1, 2022
c267e54
Merge branch 'branch-Level-8'
alexandermula Sep 1, 2022
08cf255
Organise classes into suitable packages
alexandermula Sep 3, 2022
917c4da
abstract read user input to ui class
alexandermula Sep 3, 2022
dafa0e1
add list command
alexandermula Sep 3, 2022
ab17e07
add unmark command
alexandermula Sep 3, 2022
ee3871e
add all commands
alexandermula Sep 3, 2022
2b04497
add parser logic
alexandermula Sep 3, 2022
c453a9a
fix parser logic
alexandermula Sep 3, 2022
0770b6e
add TaskList class
alexandermula Sep 3, 2022
8e27eb5
add ui logic
alexandermula Sep 3, 2022
d930758
fix storage logic
alexandermula Sep 4, 2022
ddbd5f6
clean up packages
alexandermula Sep 4, 2022
36fb04e
Merge branch 'nus-cs2103-AY2223S1:add-gradle-support' into add-gradle…
alexandermula Sep 4, 2022
b055c54
add gradle support
alexandermula Sep 4, 2022
c225250
add junit tests
alexandermula Sep 4, 2022
d2722ef
Add javadocs for TaskList
alexandermula Sep 8, 2022
d88c342
Add javadocs to all classes
alexandermula Sep 8, 2022
a5e7b67
Fix code to comply with coding standard
alexandermula Sep 8, 2022
56ab4d6
Add find function
alexandermula Sep 8, 2022
dfc760d
Merge branch 'branch-A-CodingStandard'
alexandermula Sep 8, 2022
59bf323
Merge branch 'branch-Level-9'
alexandermula Sep 8, 2022
4da3212
Add checkstyle
alexandermula Sep 8, 2022
fd0c357
Add view and image resources
alexandermula Sep 8, 2022
692246c
Add javafx
alexandermula Sep 8, 2022
4cfda08
add javaFX
alexandermula Sep 14, 2022
2bfa59e
add assert statements
alexandermula Sep 14, 2022
0567cc5
Merge pull request #2 from alexandermula/branch-A-Assertions
alexandermula Sep 14, 2022
e386799
fix code quality
alexandermula Sep 14, 2022
b668147
Merge pull request #3 from alexandermula/branch-A-CodeQuality
alexandermula Sep 14, 2022
c46ee09
Add sort command
alexandermula Sep 15, 2022
0f7a2fe
Merge pull request #4 from alexandermula/branch-C-Sort
alexandermula Sep 15, 2022
1c5c16d
Find command: add varargs to pass multiple keywords
alexandermula Sep 15, 2022
9c75ccf
Merge branch 'master' of https://github.com/alexandermula/ip
alexandermula Sep 15, 2022
bbf40fc
Merge pull request #5 from alexandermula/branch-C-Sort
alexandermula Sep 15, 2022
19c3253
Merge branch 'master' of https://github.com/alexandermula/ip
alexandermula Sep 15, 2022
ce78d08
Add enums
alexandermula Sep 15, 2022
01a6f58
Add styling to GUI
alexandermula Sep 15, 2022
ddd0c10
Add personality
alexandermula Sep 15, 2022
a0be07b
Add github page
alexandermula Sep 15, 2022
81eec33
Build jar file
alexandermula Sep 15, 2022
9de9aa0
Replace tabs usage with spaces
alexandermula Oct 16, 2022
723befa
Fix header comments
alexandermula Oct 16, 2022
59e259f
Remove dead code
alexandermula Oct 16, 2022
2bf9003
Fix package name style
alexandermula Oct 16, 2022
36401c4
Add test cases
alexandermula Oct 16, 2022
8619248
Fix header comments
alexandermula Oct 16, 2022
4562947
Fix code quality
alexandermula Oct 16, 2022
ee1e14a
Fix code quality
alexandermula Oct 16, 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
38 changes: 33 additions & 5 deletions src/main/java/Chacha.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,43 @@ public static void main(String[] args) {
System.out.println("Hello! I'm Chacha\n" + "What can I do for you?");
Scanner input = new Scanner(System.in);
String s = input.nextLine();

Choose a reason for hiding this comment

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

Maybe can name s differently? To a clearer variable

ArrayList<String> list = new ArrayList<String>();
ArrayList<Task> taskList = new ArrayList<Task>();

Choose a reason for hiding this comment

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

Good that the variable names are in camel case

Copy link

Choose a reason for hiding this comment

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

Can consider making taskList a private static final field in the class

while (!s.equals("bye")) {
if (s.equals("list")) {
for (int i = 0; i < list.size();i++) {
System.out.println(i + 1 + ". " + list.get(i));
for (int i = 0; i < taskList.size();i++) {
Task t = taskList.get(i);
System.out.println(i + 1 +
".[" +
t.getStatusIcon() +
"] " +
t.getDescription());
}

} else if (s.contains("unmark")) {
Copy link

Choose a reason for hiding this comment

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

Can consider using s.startsWith function to check if the task type is indeed the first input


String[] split = s.split("\\s+");
Task task = taskList.get(Integer.valueOf(split[1]) - 1);
task.unmarkAsDone();
System.out.println("OK, I've marked this task as not done yet:\n [" +
task.getStatusIcon() +
"] " +
task.getDescription());

} else if (s.contains("mark")) {
System.out.println(s.substring(0, 3));
String[] split = s.split("\\s+");
Task task = taskList.get(Integer.valueOf(split[1]) - 1);
System.out.println("here");
task.markAsDone();
System.out.println("Nice! I've marked this task as done:\n [" +
task.getStatusIcon() +
"] " +
task.getDescription());

} else {
list.add(s);
System.out.println("added: " + s);
Task task = new Task(s);
taskList.add(task);
System.out.println("added: " + task.getDescription());

}
s = input.nextLine();
Expand Down
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 {
private String description;
private boolean isDone;

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

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

public void unmarkAsDone() {
this.isDone = false;
}

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}

public String getDescription() {
return description;
}

}