Skip to content

Commit

Permalink
Level 2
Browse files Browse the repository at this point in the history
  • Loading branch information
euzintan committed Aug 20, 2020
1 parent 913c098 commit 193dc5b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,36 @@ public static void main(String[] args) {
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println(logo + "\nHello im Eu Zin's Duke, he spent thursday afternoon creating me cuz he forgot abt the iP");

ArrayList<String> taskList = new ArrayList<>();
ArrayList<Task> taskList = new ArrayList<>();
Duke.response(new Scanner(System.in), taskList);
}

static void response(Scanner scanner, ArrayList<String> taskList) {
static void response(Scanner scanner, ArrayList<Task> taskList) {
String userInput = scanner.nextLine();
String borders = "\n\n\\ / \\ / \\ / \\ / im not very creative \\ / \\ / \\ / \\ /\n \\ / \\ / \\ / \\ / EuZin's Duke \\ / \\ / \\ / \\ /\n\n";
if (userInput.equals("bye")) {
System.out.println(borders + "Bye. Hope to see you again soon!" + borders);
} else if (userInput.equals("list")) {
int counter = 0;
String returnString = borders + "faster do don't netflix already";
Iterator<String> taskIterator = taskList.iterator();
while(taskIterator.hasNext()) {
returnString += "\n" + (counter+1) + ". " + taskIterator.next();
Iterator<Task> taskIterator = taskList.iterator();
while (taskIterator.hasNext()) {
Task thisTask = taskIterator.next();
returnString += "\n" + (counter + 1) + ". " + thisTask.getStatusIcon() + " " + thisTask.description;
counter++;
}
System.out.println(returnString + borders);
response(new Scanner(System.in), taskList);
} else if (userInput.length() >= 4 && userInput.substring(0,4).equals("done")) {
String returnString = borders + "ok sure good job i guess\n";
int taskDone = Integer.parseInt(userInput.substring(5));
Task thisTask = taskList.get(taskDone-1);
thisTask.done();
returnString += thisTask.getStatusIcon() + " " + thisTask.description;
System.out.println(returnString + borders);
response(new Scanner(System.in), taskList);
} else {
taskList.add(userInput);
taskList.add(new Task(userInput));
System.out.println(borders + "added: " + userInput + borders);
Duke.response((new Scanner(System.in)), taskList);
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 void done(){
this.isDone = true;
}
}

0 comments on commit 193dc5b

Please sign in to comment.