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

[samriddh2145] iP #645

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 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
962daa9
Level 0 - Rename main class and message.
samriddh2145 Aug 30, 2024
19b1f75
Level 0
samriddh2145 Aug 30, 2024
93e0062
Level 1
samriddh2145 Aug 30, 2024
15bb306
Level 2
samriddh2145 Aug 30, 2024
40808b5
Level 3
samriddh2145 Aug 30, 2024
3ca6677
level4
samriddh2145 Sep 4, 2024
0265f50
Automated_Testing
samriddh2145 Sep 4, 2024
756f9de
Level5
samriddh2145 Sep 6, 2024
cf46cc2
Level6
samriddh2145 Sep 6, 2024
1cecdae
Enums
samriddh2145 Sep 6, 2024
b645e1d
Implemented saving and loading file functionality
samriddh2145 Sep 9, 2024
1460fdd
Merge branch 'branch-level-7'
samriddh2145 Sep 9, 2024
682a2a7
Chatbot now saves date and time as LocalDateTime
samriddh2145 Sep 13, 2024
484c3fc
Merge branch 'branch-Level-8'
samriddh2145 Sep 13, 2024
d150412
Added more OOP properties
samriddh2145 Sep 16, 2024
e030379
Added package
samriddh2145 Sep 16, 2024
2012375
Merge remote-tracking branch 'origin/add-gradle-support'
samriddh2145 Sep 16, 2024
dd58a5c
Add JUnit Tests
samriddh2145 Sep 16, 2024
6d4d819
Add JavaDoc comments
samriddh2145 Sep 17, 2024
37768e9
Apply coding standards
samriddh2145 Sep 19, 2024
5ff2982
Implement Level-9
samriddh2145 Sep 19, 2024
5934709
Resolve conflicts and merge branch-A-CodingStandard
samriddh2145 Sep 19, 2024
3b1822e
Resolve conflicts and merge branch-Level-9
samriddh2145 Sep 19, 2024
5be2639
Add GUI and implement Level-10
samriddh2145 Sep 19, 2024
3b1e02f
Merge branch 'branch-Level-10'
samriddh2145 Sep 19, 2024
e9f77b6
Add assert feature
samriddh2145 Sep 20, 2024
68f3ec0
Improve code quality
samriddh2145 Sep 20, 2024
3463b57
Merge pull request #2 from samriddh2145/branch-A-Assertions
samriddh2145 Sep 20, 2024
a3de517
Merge pull request #3 from samriddh2145/branch-A-CodeQuality
samriddh2145 Sep 20, 2024
8acd894
Add stats command to display task statistics
samriddh2145 Sep 20, 2024
97e452a
Fix the issue of welcome message
samriddh2145 Sep 20, 2024
b758e84
Add User Guide and Product Image
samriddh2145 Sep 21, 2024
85cef01
Update README
samriddh2145 Sep 21, 2024
1256e3c
Add changes for jar release
samriddh2145 Sep 21, 2024
af9b906
Add Launcher class
samriddh2145 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
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
# Bing User Guide

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

Expand Down
144 changes: 144 additions & 0 deletions src/main/java/Bing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import java.util.Scanner;
import java.util.ArrayList;
public class Bing {
public static void main(String[] args) {

Choose a reason for hiding this comment

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

Consider abstracting away portions of your code to helper methods and then refactoring your code to match the OOP style of coding. Kudos on the extensive error handling nonetheless!

String message = "______________________________\n"
+ "Hi! My name is Bing\n"
+ "How can I help you?\n"
+ "______________________________\n";

Choose a reason for hiding this comment

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

I notice you have many areas in your code where you are using a string of underscores to denote a line. You may consider declaring a variable, e.g. LINE, to avoid code repetition!

System.out.println(message);
Scanner scanner = new Scanner(System.in);
String input;
ArrayList<Task> tasks = new ArrayList<Task>();

while (true) {
input = scanner.nextLine().trim();
if (input.equals("Bye") || input.equals("bye")) {
System.out.println("______________________________\n"
+ "Bye. Have a good day.\n"
+ "______________________________\n");
break;
} else if (input.equals("list")) {
System.out.println("______________________________\n"
+ "All tasks in your list :\n");
for (int i=0 ; i<tasks.size() ; i++) {
System.out.println((i + 1)+". "+tasks.get(i).toString());
}
System.out.println("______________________________\n");
} else if (input.startsWith("mark")) {
try {
int x = Integer.parseInt(input.substring(5).trim());
if (x > 0 && x<=tasks.size()) {
tasks.get(x - 1).setStatus(TaskStatus.DONE);
System.out.println("______________________________\n");
System.out.println("This task is marked as done :");
System.out.println(tasks.get(x-1).toString());
System.out.println("______________________________\n");
} else {
System.out.println("Invalid Input.\n");
}
} catch (NumberFormatException e) {
System.out.println("______________________________\n");
System.out.println("Invalid Format");
System.out.println("______________________________\n");
}

} else if (input.startsWith("unmark")) {
try {
int x = Integer.parseInt(input.substring(7));
if (x>0 && x<=tasks.size()) {
tasks.get(x-1).setStatus(TaskStatus.UNDONE);
System.out.println("______________________________\n");
System.out.println("This task is marked as undone :");
System.out.println(tasks.get(x-1).toString());
System.out.println("______________________________\n");
} else {
System.out.println("Invalid Input.\n");
}
} catch (NumberFormatException e) {
System.out.println("______________________________\n");
System.out.println("Invalid Format");
System.out.println("______________________________\n");
}


} else if (input.startsWith("todo")) {
String temp = input.substring(4).trim();
if (temp.isEmpty()) {
System.out.println("Invalid Input.\n");
} else {
Task temp2 = new ToDo(temp);
tasks.add(temp2);
System.out.println("______________________________\n"
+ "Added the task:\n"
+ temp.toString() + "\n"
+ "Total tasks - " + tasks.size() + "\n"
+ "______________________________\n");
}

} else if (input.startsWith("deadline ")) {
try {
String[] segments = input.substring(9).split(" /by ");
if (segments.length < 2 || segments[0].trim().isEmpty() || segments[1].trim().isEmpty()) {
System.out.println("Invalid Input.\n");
} else {
Task temp = new Deadline(segments[0],segments[1]);
tasks.add(temp);
System.out.println("______________________________\n"
+ "Added the task:\n"
+ temp.toString() + "\n"
+ "Total tasks - " + tasks.size() + "\n"
+ "______________________________\n");
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("______________________________\n");
System.out.println("Invalid Format");
System.out.println("______________________________\n");
}


} else if (input.startsWith("event ")) {
try {
String[] segments = input.substring(6).split(" /from ");
if (segments.length<2) {
System.out.println("Invalid Input.\n");
} else {
String[] segments2 = segments[1].split(" /to ");
Task temp = new Event(segments[0],segments2[0],segments2[1]);
tasks.add(temp);
System.out.println("______________________________\n"
+ "Added the task:\n"
+ temp.toString() + "\n"
+ "Total tasks - " + tasks.size() + "\n"
+ "______________________________\n");
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("______________________________\n");
System.out.println("Invalid Format");
System.out.println("______________________________\n");
}

} else if (input.startsWith("delete")) {
try {
int x = Integer.parseInt(input.substring(7).trim());
if (x>0 && x<=tasks.size()) {
Task removedTask = tasks.remove(x - 1);
System.out.println("______________________________\n");
System.out.println("Task removed :");
System.out.println(removedTask.toString());
System.out.println("Total tasks - " + tasks.size() + "\n");
System.out.println("______________________________\n");
} else {
System.out.println("Invalid Input.\n");
}
} catch (NumberFormatException e) {
System.out.println("______________________________\n");
System.out.println("Invalid Format");
System.out.println("______________________________\n");
}
} else {
System.out.println("Invalid Input.\n");
}
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Deadline extends Task {

private String deadline;

public Deadline(String info, String deadline) {

Choose a reason for hiding this comment

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

Consider adding a JavaDoc comment for this as it will likely cause a Checkstyle error, since public constructors are required to have such a comment.

super(info);
this.deadline = deadline;
}
@Override
public String toString() {
return "[D]" + "[" + getStatus().getStatusSymbol() + "]" + " " + getInfo() + " (by: " + deadline + ")";
}

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

This file was deleted.

15 changes: 15 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Event extends Task {
private String from;
private String to;
public Event(String info, String from, String to) {
super(info);
this.from = from;
this.to = to;
}


Choose a reason for hiding this comment

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

Nit: Unnecessary newline

@Override
public String toString() {
return "[E]" + "[" + getStatus().getStatusSymbol() +"]"+ " " + getInfo() + " " + " (from: " + from + " to: " + to + ")";
}
}
21 changes: 21 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public abstract class Task {
private String info;
private TaskStatus isDone;

public Task(String info) {

Choose a reason for hiding this comment

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

Consider adding a JavaDoc comment to the explain constructor for this class.

this.info = info;
this.isDone = TaskStatus.UNDONE;
}

public String getInfo() {
return info;
}
public TaskStatus getStatus() {
return isDone;
}
public void setStatus(TaskStatus status) {
this.isDone = status;
}

public abstract String toString();
}
16 changes: 16 additions & 0 deletions src/main/java/TaskStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public enum TaskStatus {
DONE("X"),
UNDONE(" ");

private String StatusSymbol;

TaskStatus(String StatusSymbol) {
this.StatusSymbol = StatusSymbol;
}

public String getStatusSymbol() {

Choose a reason for hiding this comment

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

Consider adding a Javadoc comment for this. Specifically, what is the status that is returned about.

return this.StatusSymbol;
}


}
13 changes: 13 additions & 0 deletions src/main/java/ToDo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.nio.charset.StandardCharsets;

public class ToDo extends Task {

public ToDo(String info) {
super(info);
}

@Override
public String toString() {
return "[T]" + "[" + getStatus().getStatusSymbol() + "]" + " " + getInfo();
}
}
67 changes: 61 additions & 6 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,62 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
______________________________
Hi! My name is Bing
How can I help you?
______________________________

______________________________
Added the task:
[D][ ] Do Assignment (by: Friday)
Total tasks - 1
______________________________

______________________________
Added the task:
[T][ ] write essay
Total tasks - 2
______________________________

______________________________
All tasks in your list :

1. [D][ ] Do Assignment (by: Friday)
2. [T][ ] write essay
______________________________

______________________________
Added the task:
[E][ ] group meet (from: Thurs 4pm to: 6pm)
Total tasks - 3
______________________________

______________________________

This task is marked as done :
[T][X] write essay
______________________________

______________________________
All tasks in your list :

1. [D][ ] Do Assignment (by: Friday)
2. [T][X] write essay
3. [E][ ] group meet (from: Thurs 4pm to: 6pm)
______________________________

______________________________

This task is marked as undone :
[T][ ] write essay
______________________________

______________________________
All tasks in your list :

1. [D][ ] Do Assignment (by: Friday)
2. [T][ ] write essay
3. [E][ ] group meet (from: Thurs 4pm to: 6pm)
______________________________

______________________________
Bye. Have a good day.
______________________________

9 changes: 9 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
deadline Do Assignment /by Friday
todo write essay
list
event group meet /from Thurs 4pm /to 6pm
mark 2
list
unmark 2
list
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 Bing < 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 Bing < input.txt > ACTUAL.TXT

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