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

Ananda Lye iP #65

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f4af9fa
Level 0. Greet
ananda-lye Jan 27, 2020
36e9b75
Level 1. Greet, Echo, Exit
ananda-lye Jan 27, 2020
20de280
Level 2. Add, List
ananda-lye Jan 27, 2020
d454993
Level-3: Mark as Done
ananda-lye Jan 28, 2020
e5e44cd
Level-3: Mark as Done (fixed response bug)
ananda-lye Jan 28, 2020
6382975
Fixed Coding Standard Violation
ananda-lye Feb 4, 2020
69c2051
Level 4. ToDos, Events, Deadlines
ananda-lye Feb 4, 2020
d4e6715
Level 4. ToDos, Events, Deadlines
ananda-lye Feb 4, 2020
374e891
Quick Fix Solution only.
ananda-lye Feb 12, 2020
b716134
Minimal Solution for A-Packages
ananda-lye Feb 12, 2020
01fac6a
Quick-Fix solution
ananda-lye Feb 12, 2020
ad87997
Merge branch 'branch-Level-5'
ananda-lye Feb 12, 2020
e3eac76
Converted to Switch statements, simplified Tokenization. Still lackin…
ananda-lye Feb 16, 2020
110af11
Fixed arrow-head violation
ananda-lye Feb 16, 2020
b51628a
Added Error Handling
ananda-lye Feb 16, 2020
16a69ff
Level-6 Included delete instruction and implemented as ArrayList
ananda-lye Feb 16, 2020
a5fc679
no message
ananda-lye Feb 22, 2020
10dfbdf
completed level-7 properly
ananda-lye Feb 22, 2020
5ed657a
completed level-7 properly again
ananda-lye Feb 22, 2020
b989408
changed filepath to an absolute
ananda-lye Feb 22, 2020
31e4c3e
level-9 added "find" function
ananda-lye Feb 23, 2020
3c8e855
Created More OOP Classes
ananda-lye Feb 24, 2020
279c74f
More OOP incomplete
ananda-lye Feb 24, 2020
13a6c1c
added TaskList class
ananda-lye Feb 24, 2020
0b3f933
Partial JavaDocs
ananda-lye Feb 29, 2020
67d87bd
JavaDocs more complete. Bug Found.
ananda-lye Feb 29, 2020
99c7b17
fixed bug - tentative solution
ananda-lye Feb 29, 2020
78b4752
Complete JavaDocs and fixed bug of out of bounds indexes
ananda-lye Mar 1, 2020
66c26ad
Completed JavaDoc, Jar and User Guide
ananda-lye Mar 1, 2020
f88b4c9
added more JavaDoc
ananda-lye Mar 1, 2020
0ba4500
Fixed typo in Readme
ananda-lye Mar 1, 2020
e868f96
Update README.md
ananda-lye Mar 2, 2020
e8b94c4
Update README.md
ananda-lye Mar 2, 2020
34826cc
Testing update
ananda-lye Mar 2, 2020
46a26b3
Fixed formatting issues
ananda-lye Mar 2, 2020
d6c44f4
Attempt fix
ananda-lye Mar 2, 2020
7862155
Attempt Fix
ananda-lye Mar 2, 2020
0bb1127
attempt fix
ananda-lye Mar 2, 2020
340cd7b
Update README.md
ananda-lye Mar 2, 2020
fa99f5b
Final Attempt to fix formatting
ananda-lye Mar 2, 2020
be493f3
Update README.md
ananda-lye Mar 2, 2020
e72ccd1
Fixed Final
ananda-lye Mar 2, 2020
0894cb3
fixed bye command highlighting
ananda-lye Mar 2, 2020
8b25f16
Changed tick and cross symbols. Accounted for invalid indexes.
ananda-lye Mar 3, 2020
58b9221
Fixed bug with empty 'find' description
ananda-lye Mar 3, 2020
e93cada
Merge branch 'master' of https://github.com/ananda-lye/duke
ananda-lye Mar 3, 2020
c069fa0
Updated UserGuide, undo README replace
ananda-lye Mar 3, 2020
95f8b2b
FIx Boolean function coding standard violation
ananda-lye Mar 3, 2020
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
46 changes: 40 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
import java.util.Scanner;
import java.util.Arrays;

public class Duke {

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String greeting = "Hello! I'm Duke\n" + "What can I do for you?";
String goodbye = "Bye. Hope to see you again soon!";
System.out.println(greeting);

Task[] tasklist = new Task[100];
Copy link

Choose a reason for hiding this comment

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

try to avoid using 'magic numbers'


Scanner scanner = new Scanner(System.in);
int flag = 0;
Copy link

Choose a reason for hiding this comment

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

variable names can be more descriptive to facilitate understanding.
use boolean type instead of int type, phrase like a question eg. isExit

int index = 0;
Copy link

Choose a reason for hiding this comment

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

variable names can be more descriptive to facilitate understanding


while (flag == 0) {
String userinput = scanner.nextLine();
if (userinput.equals("bye")) {
System.out.println(goodbye);
flag = 1;
} else if (userinput.equals("list")){
for (int i = 1; i <= index; i++) {
System.out.print(i);
System.out.print(".[" + tasklist[i-1].getStatusIcon() + "] " + tasklist[i-1].description + "\n");
}
} else if (userinput.startsWith("done")){
String IndexOfItem = userinput.substring(5);
Copy link

Choose a reason for hiding this comment

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

use camelCase "indexOfItem"

int ID = Integer.valueOf(IndexOfItem) - 1;
Copy link

Choose a reason for hiding this comment

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

use descriptive names to differentiate between int type and String type variable
eg. "indexString" & "indexInt"

System.out.println("Nice! I've marked this task as done: ");
System.out.println(tasklist[ID].markAsdone());
} else {
System.out.println("added: " + userinput);
tasklist[index] = new Task(userinput);
index++;
}
}



}


}
21 changes: 21 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class Task {
protected String description;
protected boolean isDone;

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

public String getStatusIcon() {
return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols
}


public String markAsdone () {
Copy link

Choose a reason for hiding this comment

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

use camelCase i.e. markAsDone

this.isDone = true;
return ("[" + this.getStatusIcon() + "] "+ this.description);
}


}