Skip to content

Commit

Permalink
level-3
Browse files Browse the repository at this point in the history
  • Loading branch information
CEGLincoln committed Aug 23, 2019
1 parent 039658d commit dffa4d5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
47 changes: 32 additions & 15 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,53 @@
import java.util.*;

public class Duke{
public static void printStr(String str) {
System.out.println(str);
}

public static void main(String[] args) {
//DECLARE
String str = "This is the\n"
+ " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n\n"
+ "Hello! What can I do for you?";
+ " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n\n"
+ "Hello! What can I do for you?";
Scanner scanner = new Scanner(System.in);
Boolean stay = true;
List<String> stuff = new ArrayList<String>();
//SHOW
System.out.println(str);
//UH OH
ArrayList<Task> stuff = new ArrayList<Task>();
int x = 0;

//START HERE
printStr(str);
while(stay){
str = scanner.nextLine();
switch(str){
String[] part = str.split(" ", 2);
switch(part[0]){
case "bye":
stay = false;
break;
case "done":
x = Integer.parseInt(part[1]) - 1;
stuff.get(x).markAsDone();
printStr("Nice! I've marked this task as done:");
printStr("[" + stuff.get(x).getStatusIcon() + "] " + stuff.get(x).getDescription());
break;
case "list":
System.out.println(stuff);
printStr("Here are the tasks in your list:");
x = 0;
for(Task t : stuff){
x++;
printStr(x + ".[" + t.getStatusIcon() + "] " + t.getDescription());
}
break;
default:
stuff.add(str);
System.out.println("added: " + str);
stuff.add(new Task(str));
printStr("added: " + str);
}
}
System.out.println("Bye. Hope to see you again soon!");
printStr("Bye. Hope to see you again soon!");
scanner.close();
}
}
23 changes: 23 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//import java.util.*;

public class Task {
protected String description;
protected boolean isDone;

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

public String getDescription() {
return this.description;
}

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

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

0 comments on commit dffa4d5

Please sign in to comment.