Skip to content
Open
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ab76983
Level-0 Increment, Greet and Exit message
SpeciLiam Jan 27, 2023
66f05b6
Level 1. Greet, Echo, Exit
SpeciLiam Jan 27, 2023
326cf60
Level 2. Add, List
SpeciLiam Jan 27, 2023
e77c524
LevevlLevel 3. Mark as Done
SpeciLiam Jan 31, 2023
2cc0131
A-CodingStandard
SpeciLiam Jan 31, 2023
489244b
Level 4. ToDos, Events, Deadlines
SpeciLiam Feb 2, 2023
9cc6ba3
A-CodeQuality
SpeciLiam Feb 2, 2023
9939b56
added class DukeException.java and switched from if statement structu…
SpeciLiam Feb 8, 2023
c8898cc
Added exception handling for todo and unknown command
SpeciLiam Feb 9, 2023
c233d69
A-Packages
SpeciLiam Feb 9, 2023
a760d20
Level 6. Delete
SpeciLiam Feb 15, 2023
238fb85
adding File Paths_1
SpeciLiam Feb 15, 2023
acd898a
Level 7. Save
SpeciLiam Feb 15, 2023
6940bc1
Merge branch 'branch-Level-6' into branch-Level-7
SpeciLiam Feb 15, 2023
96b58be
Changes for code readibility
SpeciLiam Feb 15, 2023
804bf2e
Merge Conflicts with branch 6 and 7
SpeciLiam Feb 15, 2023
d9dc7c1
Code Cleanup
SpeciLiam Feb 15, 2023
99237ca
A-MoreOOP
SpeciLiam Mar 2, 2023
f9bb7fe
Code Cleanup
SpeciLiam Mar 3, 2023
73543ab
Level 9. Find and code clean up
SpeciLiam Mar 3, 2023
cef26a2
Code Cleanup
SpeciLiam Mar 3, 2023
5886c71
A-JavaDoc
SpeciLiam Mar 3, 2023
c12849d
A-UserGuide
SpeciLiam Mar 3, 2023
eee98c8
Code clean-up and error handling better
SpeciLiam Mar 3, 2023
1b6cb39
Coding Standard Upkeep
SpeciLiam Mar 3, 2023
c222d8e
Commiting for jar related issues - made a change in code so that I ca…
SpeciLiam Mar 4, 2023
660cda3
Commiting for jar related issues - made a change in code so that I ca…
SpeciLiam Mar 4, 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
97 changes: 97 additions & 0 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,107 @@
import java.util.ArrayList;
import java.util.Scanner;

public class Duke {

public Duke() {

}

public static void main(String[] args) {

Duke duke = new Duke();
ArrayList<String> userInputs = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Like your naming for the ArrayList!

boolean isRun = true;
Scanner scan = new Scanner(System.in);
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

greetUser();

while (true) {
String input = scan.nextLine();
if (input.equals("bye")) {
break;
}
if (input.equals("list")) {
listOut(userInputs);
} else if (input.length() >= 4 && input.substring(0, 4).equals("mark")) {
String[] tmpArr = input.split(" ");
markDone(Integer.parseInt(tmpArr[1]), userInputs, true);
} else if (input.length() >= 6 && input.substring(0, 6).equals("unmark")) {
String[] tmpArr = input.split(" ");
markDone(Integer.parseInt(tmpArr[1]), userInputs, false);
} else {
addToList(input, userInputs);
}
//echoCmd(input);


}
exit();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just nitpicking, but would be nice if there was a space after this :^)

public static void markDone(int index, ArrayList<String> userInputs, boolean isMark) {
if (isMark) {
String org = userInputs.get(index - 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.

I think it would be better to use a more descriptive name -- not sure what org means here

String newStr = org.replace("[ ]", "[X]");
System.out.println(newStr);
userInputs.set(index - 1, newStr);
} else {
String org = userInputs.get(index - 1);
String newStr = org.replace("[X]", "[ ]");
System.out.println(newStr);
userInputs.set(index - 1, newStr);
}
System.out.println("\t____________________________________________________________");
if (isMark) {
System.out.println("\t Nice! I've marked this task as done:");
} else {
System.out.println("\t OK, I've marked this task as not done yet:");
}
int idx = userInputs.get(index - 1).indexOf("[");
System.out.println("\t" + " " + userInputs.get(index - 1).substring(idx));
System.out.println("\t____________________________________________________________");
}
public static void addToList(String cmd, ArrayList<String> userInputs) {
System.out.println("\t____________________________________________________________");
System.out.println("\tadded: " + cmd);
System.out.println("\t____________________________________________________________");
userInputs.add(cmd);
userInputs.set(userInputs.size() - 1, userInputs.size() + ". [ ] " + userInputs.get(userInputs.size() - 1));
}

public static void listOut(ArrayList<String> userInputs) {
System.out.println("\t____________________________________________________________");
for (int i = 0; i < userInputs.size(); i++) {
System.out.println("\t" + userInputs.get(i));
}
System.out.println("\t____________________________________________________________");

}
public static void echoCmd(String cmd) {
System.out.println("\t____________________________________________________________");
System.out.println("\t " + cmd);
System.out.println("\t____________________________________________________________");

}

public static void greetUser() {
System.out.println("\t____________________________________________________________");
System.out.println("\tHello! I'm Duke");
System.out.println("\tWhat can I do for you?");
System.out.println("\t____________________________________________________________");

}

public static void exit() {
System.out.println("\t____________________________________________________________");
System.out.println("\tBye. Hope to see you again soon!");
System.out.println("\t____________________________________________________________");

}

}