Skip to content
27 changes: 1 addition & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
# Duke project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

## Setting up in Intellij

Prerequisites: JDK 17, update Intellij to the most recent version.

1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first)
1. Open the project into Intellij as follows:
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 17** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
1. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```

**Warning:** Keep the `src\main\java` folder as the root folder for Java files (i.e., don't rename those folders or move Java files to another folder outside of this folder path), as this is the default location some tools (e.g., Gradle) expect to find Java files.
Ryan's Project!
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke User Guide
# Siao User Guide

// Update the title above to match the actual product name

Expand Down
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

96 changes: 96 additions & 0 deletions src/main/java/Siao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import java.util.Arrays;
import java.util.Scanner;

public class Siao {

public enum Label{
TODO,
EVENT,
DEADLINE
}

public static void printDividerLine(){
System.out.println("---------------------------------");
}

public static void printList(Task[] list) {
printDividerLine();
int indexNumber = 1;
for (Task task : list) {
if (task == null) {
System.out.println("-----------End Of List-----------");
break;
}
System.out.printf("%d. [T][%s] %s\n", indexNumber, task.getStatusIcon(), task.getDescription());
indexNumber++;
}
printDividerLine();
}


public static void main(String[] args) {
System.out.println("Hello! I'm Siao!!");

Scanner input = new Scanner(System.in);
System.out.println("What can I do for you?");
String line = input.nextLine();

Task[] list = new Task[100];
int matchCount = 0;

while(!line.equalsIgnoreCase("bye")){
String[] splitInput = line.split(" ");
String command = splitInput[0];

switch (command){
// to add 3 more cases: TODO, EVENT and DEADLINE
case "list":
printList(list);
line = input.nextLine();
break;

case "todo":
list[matchCount] = new Task(line);
matchCount++;
Todo.printAction(line);
line = input.nextLine();
break;

case "mark":
int markIndex = Integer.parseInt(splitInput[1]) - 1;
list[markIndex].markDone();
list[markIndex].printMarkDone();
line = input.nextLine();
break;

case "unmark":
int unmarkIndex = Integer.parseInt(splitInput[1]) - 1;
list[unmarkIndex].markUndone();
list[unmarkIndex].printMarkUndone();
line = input.nextLine();
break;

default:
list[matchCount] = new Task(line);
matchCount++;
System.out.println(line);
line = input.nextLine();
break;
}
}

System.out.println("---------------------------------");
System.out.println("Bye. Hope to see you again soon!");
}
}

/* New Idea:
Everytime I input something, depending on the 1st word that I input, I will store the line into the task array
The task array will create a String
Each element in the String array will contain the following:
[Label of Task][Marker] "description"

Task class will only contain information about the Mark and the description
my subclasses will contain information about the label
*/

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

public Task(String description) { // constructor of the task
this.description = description;
this.isDone = false; // to remove
}

public String getStatusIcon() {
if (isDone) {
return "X";
}
return " ";
}

public String getDescription() {
return description;
}

public void markDone(){
isDone = true;
}

public void markUndone(){
isDone = false;
}

public void printMarkDone() {
System.out.println("Good job on completing the task!");
System.out.printf("[%s] %s\n", getStatusIcon(), description);
Siao.printDividerLine();
}

public void printMarkUndone() {
System.out.println("Okay we haven't finished it yet!");
System.out.printf("[%s] %s\n", getStatusIcon(), description);
Siao.printDividerLine();
}

public static void printAction(String action){
Siao.printDividerLine();
System.out.printf("added: " + action + "\n");
Siao.printDividerLine();
}

}
26 changes: 26 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class Todo extends Task{

public Siao.Label taskType = Siao.Label.TODO;

public Todo(String Description) {
super(Description);
isDone = false;
}

public static String toDoLabel(){
return "T";
}

public static void printAction(String action){
Siao.printDividerLine();
System.out.printf("Got it! Added this task in!\n [%s][ ] %s\n",toDoLabel(),action);
Siao.printDividerLine();
}

public void printMarkDone() {
System.out.println("Good job on completing the task!");
System.out.printf("[%s][%s] %s\n",toDoLabel(), getStatusIcon(), description);
Siao.printDividerLine();
}

}
2 changes: 1 addition & 1 deletion text-ui-test/runtest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 (
REM no error here, errorlevel == 0

REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
java -classpath ..\bin Siao < input.txt > ACTUAL.TXT

REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT