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

[Nihirraa] ip #643

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
68c58c1
Add Gradle support
May 24, 2020
03523ec
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
81a9c53
build.gradle: Prevent generating a second JAR file
aureliony Jul 16, 2024
4853d37
Rename main class and add greeting - Level-0
Nihirraa Aug 30, 2024
d46d608
Level1
Nihirraa Aug 30, 2024
7408eb1
Level2
Nihirraa Aug 30, 2024
71fd7e2
Level3
Nihirraa Aug 30, 2024
7f93304
Level 4
Nihirraa Sep 3, 2024
9148f8e
Added Automated Testing
Nihirraa Sep 4, 2024
87fd4a7
Level5
Nihirraa Sep 4, 2024
0aba9e7
Level6
Nihirraa Sep 4, 2024
aa2cb29
Added TaskType Enum
Nihirraa Sep 6, 2024
31d79ce
Add Enums
Nihirraa Sep 6, 2024
9c7333f
Added saving functionality for tasks
Nihirraa Sep 7, 2024
5d2a974
Resolved merge conflict in src/main/java/TaskType.java
Nihirraa Sep 7, 2024
68cc04a
Add date formats
Nihirraa Sep 9, 2024
b1dbb02
Add date formats
Nihirraa Sep 9, 2024
151467e
Merge branch 'branch-Level-8'
Nihirraa Sep 9, 2024
64d2b58
Added OOP properties to source code
Nihirraa Sep 13, 2024
623b278
Add gradle build files
Nihirraa Sep 13, 2024
bd882b8
Merge remote-tracking branch 'origin/add-gradle-support'
Nihirraa Sep 13, 2024
ef15ad5
Gradle build file
Nihirraa Sep 13, 2024
1b4e91b
add packages
Nihirraa Sep 13, 2024
451b292
Added JUnit Testing
Nihirraa Sep 14, 2024
d12aa50
Add JavaDoc comments to classes and methods
Nihirraa Sep 14, 2024
ec5dd68
Applied coding standards
Nihirraa Sep 14, 2024
d19ade8
Added finding function
Nihirraa Sep 16, 2024
31bc0f0
Merge branch 'branch-A-CodingStandard'
Nihirraa Sep 16, 2024
9b22e2a
Merge branch 'branch-Level-9'
Nihirraa Sep 16, 2024
480ce49
Added GUI for my chatbot
Nihirraa Sep 19, 2024
11f70a2
Add changes for A-Assertions
Nihirraa Sep 19, 2024
94901c4
Add changes for A-CodeQuality
Nihirraa Sep 19, 2024
8c98153
Add changes for A-Streams
Nihirraa Sep 19, 2024
6f6d6b3
Add minute changes to code for better comprehension
Nihirraa Sep 20, 2024
bb1c609
Merge pull request #2 from Nihirraa/branch-A-Assertions
Nihirraa Sep 20, 2024
ccf9cc0
Merge pull request #3 from Nihirraa/branch-A-CodeQuality
Nihirraa Sep 20, 2024
1047d4c
Merge pull request #4 from Nihirraa/branch-A-Streams
Nihirraa Sep 20, 2024
b0c08d9
Add assertions to MainWindow class
Nihirraa Sep 20, 2024
f1debb3
Ensure conflict detection between EventTask and DeadlineTask
Nihirraa Sep 20, 2024
e37743b
Add more features to improve code quality
Nihirraa Sep 20, 2024
61cc4b5
Add User Guide
Nihirraa Sep 21, 2024
d82883b
Add Ui.png
Nihirraa Sep 21, 2024
45aa026
Make final changes before releasing jar file
Nihirraa Sep 21, 2024
7a0d3f1
Update README.md
Nihirraa Sep 26, 2024
5295065
Fix README.md
Nihirraa Sep 26, 2024
04780ef
Final changes for jar file
Nihirraa Sep 30, 2024
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# Espresso 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.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 17, update Intellij to the most recent version.
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.
3. 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:
3. After that, locate the `src/main/java/Espresso.java` file, right-click it, and choose `Run Espresso.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
____ _
Expand Down
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
# Espresso 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.

Binary file added src/main/java/Espresso.class
Binary file not shown.
140 changes: 140 additions & 0 deletions src/main/java/Espresso.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import java.util.Scanner;
import java.util.ArrayList;
public class Espresso {
private ArrayList<Task> tasks ;
private int count;

public Espresso() {
tasks = new ArrayList<>();
count = 0;
}

void addToList(String str) {
Task task = null;
try {
if (str.startsWith("todo")) {

Choose a reason for hiding this comment

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

You may change the if-statement indentation to indentation to once (4 spaces) instead of twice.

String status = str.substring(4).trim();
if (status.isEmpty())
throw new IllegalArgumentException("Description of todo task is required");
task = new todoTask(status);
} else if (str.startsWith("deadline")) {
String split[] = str.substring(8).split(" /by");
String status = split[0].trim();
if (status.isEmpty())
throw new IllegalArgumentException("Description of deadline task is required");
task = new deadlineTask(status, split[1].trim());
} else if (str.startsWith("event")) {
String split1[] = str.substring(5).split(" /from ");
String status = split1[0].trim();
if (status.isEmpty())
throw new IllegalArgumentException("Description of event task is required");
String split2[] = split1[1].split(" /to ");
task = new eventTask(status, split2[0].trim(), split2[1].trim());
} else {
throw new IllegalArgumentException("Random Input! I don't know what that means :(");
}
tasks.add(task);
System.out.println("____________________________________________________________");
System.out.println("Got it. I've added this task:");
System.out.println(" " + task);
if (count == 0)
System.out.println("Now you have " + (count + 1) + " task in the list.");
else
System.out.println("Now you have " + (count + 1) + " tasks in the list.");
System.out.println("____________________________________________________________");
count++;
}
catch (IllegalArgumentException e) {
System.out.println("____________________________________________________________");
System.out.println("Oops! " + e.getMessage());
System.out.println("____________________________________________________________");
}
}

void deleteTask(int position) {
System.out.println("____________________________________________________________");
Task rem = tasks.remove(position);
count--;
System.out.println("Noted. I've removed this task:");
System.out.println(" " + rem);
if (count == 1)
System.out.println("Now you have " + count + " task in the list.");
else
System.out.println("Now you have " + count + " tasks in the list.");
System.out.println("_________________________________________");
}

void printList() {
System.out.println("____________________________________________________________");
for (int i = 0; i < count; i++) {
int num = i + 1;
System.out.println(num + ". " + tasks.get(i));
}
System.out.println("____________________________________________________________");
}

void process() {
System.out.println("_________________________________________");
System.out.println("Hello! I'm Espresso");
System.out.println("What can I do for you?");
System.out.println("_________________________________________");
Scanner sc = new Scanner(System.in);
String str;
while (true) {
str = sc.nextLine();

if (str.equals("bye")) {
System.out.println("____________________________________________________________");
System.out.println("Bye. Hope to see you again soon!");
System.out.println("____________________________________________________________");
break;
} else if (str.startsWith("mark ")) {
String extractNum = str.substring(str.indexOf(' ') + 1).trim();
int pos = Integer.valueOf(extractNum);
markTask(pos - 1);
} else if (str.startsWith("unmark ")) {
String extractNum = str.substring(str.indexOf(' ') + 1).trim();
int pos = Integer.valueOf(extractNum);
unmarkTask(pos - 1);
}else if (str.equals("list")) {
printList();
} else if (str.startsWith("delete ")) {
String extractNum = str.substring(str.indexOf(' ') + 1).trim();
int pos = Integer.valueOf(extractNum);
deleteTask(pos - 1);
}
else {
addToList(str);
}
}
sc.close();
}
void markTask(int position) {
System.out.println("_________________________________________");
if (position >= 0 && position < count) {
tasks.get(position).mark();
System.out.println("Nice! I've marked this task as done:");
System.out.println(" " + tasks.get(position));
System.out.println("_________________________________________");
} else {
System.out.println("Invalid task number.");
}
}

private void unmarkTask(int position) {
System.out.println("_________________________________________");
if (position >= 0 && position < count) {
tasks.get(position).unmark();
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(" " + tasks.get(position));
System.out.println("_________________________________________");
} else {
System.out.println("Invalid task number.");
}
}

public static void main(String[] args) {
Espresso esp = new Espresso();
esp.process();
}
}
Binary file added src/main/java/Task.class
Binary file not shown.
27 changes: 27 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Task {
private String status;
private boolean isDone;

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

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

public void unmark() {
this.isDone = false;
}

public String getIcon() {
return (isDone ? "[X]" : "[ ]");
}

@Override
public String toString() {
return getIcon() + " " + status;
}
}

Binary file added src/main/java/deadlineTask.class
Binary file not shown.
14 changes: 14 additions & 0 deletions src/main/java/deadlineTask.java

Choose a reason for hiding this comment

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

You may rename your class to be capitalised at the first letter.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class deadlineTask extends Task {
private String dl;

deadlineTask(String status, String dl) {
super(status);
this.dl = dl;
}

@Override
public String toString() {
String icon = "[D]";
return icon + super.toString() + " (by: " + dl + ")";
}
}
Binary file added src/main/java/eventTask.class
Binary file not shown.
14 changes: 14 additions & 0 deletions src/main/java/eventTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class eventTask extends Task{
private String starts,ends;

Choose a reason for hiding this comment

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

You may put a whitespace after the comma.

Suggested change
private String starts,ends;
private String starts, ends;


eventTask(String status, String starts, String ends){
super(status);
this.starts = starts;
this.ends = ends;
}
@Override
public String toString() {
String icon = "[E]";
return icon + super.toString() + " (from: " + starts + " to: " + ends + ")";
}
}
Binary file added src/main/java/todoTask.class
Binary file not shown.
12 changes: 12 additions & 0 deletions src/main/java/todoTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class todoTask extends Task{
Copy link

Choose a reason for hiding this comment

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

class name should start with capital letter

public todoTask(String status) {
super(status);
}

@Override
public String toString() {
String icon = "[T]";
return icon + super.toString();
}

}
47 changes: 40 additions & 7 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

_________________________________________
Hello! I'm Espresso
What can I do for you?
_________________________________________
____________________________________________________________
Got it. I've added this task:
[T][ ] read book
Now you have 1 task in the list.
____________________________________________________________
____________________________________________________________
Got it. I've added this task:
[D][ ] return book (by: Sunday)
Now you have 2 tasks in the list.
____________________________________________________________
____________________________________________________________
Got it. I've added this task:
[E][ ] project meeting (from: Mon 2pm to: 4pm)
Now you have 3 tasks in the list.
____________________________________________________________
____________________________________________________________
1. [T][ ] read book
2. [D][ ] return book (by: Sunday)
3. [E][ ] project meeting (from: Mon 2pm to: 4pm)
____________________________________________________________
_________________________________________
Nice! I've marked this task as done:
[T][X] read book
_________________________________________
____________________________________________________________
1. [T][X] read book
2. [D][ ] return book (by: Sunday)
3. [E][ ] project meeting (from: Mon 2pm to: 4pm)
____________________________________________________________
_________________________________________
OK, I've marked this task as not done yet:
[T][ ] read book
_________________________________________
____________________________________________________________
Bye. Hope to see you again soon!
____________________________________________________________
8 changes: 8 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
todo read book
deadline return book /by Sunday
event project meeting /from Mon 2pm /to 4pm
list
mark 1
list
unmark 1
bye
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 Espresso < input.txt > ACTUAL.TXT

REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT
2 changes: 1 addition & 1 deletion text-ui-test/runtest.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ then
fi

# 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 Espresso < input.txt > ACTUAL.TXT

# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT
Expand Down