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

[Saha9616] iP #371

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
4f0dba8
did the level 1 task
Saha9616 Jan 19, 2023
81316d4
did the level 2 task
Saha9616 Jan 20, 2023
ca436b5
did the level 3 task
Saha9616 Jan 21, 2023
4afa0d0
did the level 4 task
Saha9616 Jan 25, 2023
23ceeaf
did automated text ui testing
Saha9616 Jan 28, 2023
8b74572
did error handling
Saha9616 Jan 29, 2023
280dd89
added feature to delete
Saha9616 Jan 29, 2023
347743d
added way to store data
Saha9616 Feb 20, 2023
a23db4d
improved storage
Saha9616 Feb 20, 2023
182c772
merged with level 7
Saha9616 Feb 20, 2023
a387450
made changes to the accepted format of time
Saha9616 Feb 20, 2023
b15e2c2
merged with level 8
Saha9616 Feb 20, 2023
ea355bb
worked on OOP principles
Saha9616 Feb 22, 2023
1ca4046
merging with more OOP
Saha9616 Feb 22, 2023
29fd30c
created packages
Saha9616 Feb 23, 2023
a106830
merge with gradle branch
Saha9616 Feb 23, 2023
449811f
add J-unit testing
Saha9616 Feb 26, 2023
eb60dac
created jar file
Saha9616 Feb 26, 2023
d567558
added java docs
Saha9616 Feb 26, 2023
d7ad960
update java docs
Saha9616 Mar 6, 2023
7d5efaa
Update coding standard
Saha9616 Mar 6, 2023
0eaeda1
Add find feature
Saha9616 Mar 6, 2023
6556b62
Merge branch 'branch-A-CodingStandard'
Saha9616 Mar 6, 2023
7c67085
Fix merge conflict
Saha9616 Mar 6, 2023
c379f16
added javafx
Saha9616 Mar 6, 2023
cac14c4
Merge branch 'branch-JavaFX-Tutorial'
Saha9616 Mar 6, 2023
8e363ce
Update User Guide'
Saha9616 Mar 7, 2023
5476dcc
made some changes
Saha9616 Mar 7, 2023
e990d89
add bcd extension
Saha9616 Mar 7, 2023
9a72ac2
Add assertions
Saha9616 Mar 7, 2023
dcd13e3
Merge branch 'branch-A-Assertions'
Saha9616 Mar 7, 2023
79a2770
Update UG
Saha9616 Mar 7, 2023
e2dcd93
Update Coding Standard
Saha9616 Mar 7, 2023
579e5b8
Update Code Quality
Saha9616 Mar 7, 2023
9400f1e
Merge pull request #2 from Saha9616/branch-A-CodeQuality
Saha9616 Mar 7, 2023
2598518
Make final touch up
Saha9616 Mar 7, 2023
3bb90aa
final changes
Saha9616 Mar 20, 2023
96d046d
Merge branch 'branch-fixes'
Saha9616 Mar 20, 2023
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
24 changes: 24 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
public class Deadline extends Task{
Copy link

Choose a reason for hiding this comment

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

Your files are missing package declarations

Choose a reason for hiding this comment

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

Should the classes be in a package?



public Deadline(String str1) {
super(str1);
}

String[] mainSplit = super.task_name.split(" ", 2);
String name = mainSplit[1]; // gives "return book /by Sunday"
String[] StrList = name.split(" /by ", 2); //gives ["return book", "Sunday"]
String nameMain = StrList[0]; //gives "return book"
String dl = "(by: " + StrList[1] + ")"; //gives "by: Sunday"


@Override
public String toString() {
if(super.status == true) {
return "[D][X] " + nameMain + " " + dl;
}
else {
return "[D][ ] " + nameMain + " " + dl;
}
}
}
99 changes: 91 additions & 8 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,93 @@
import java.util.*;
Copy link

Choose a reason for hiding this comment

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

import.* syntax is discouraged

import java.util.ArrayList;
public class Duke {
public static Scanner sc = new Scanner(System.in);
public static ArrayList<Task> lst = new ArrayList<Task>();
public static void add_to_list(String str) throws InvalidCommandException, NoDescriptionException{

if((str.split(" ", 2).length == 1)) {
throw new NoDescriptionException();
}
else if((str.split(" ", 2)[0]).equals("todo")) {
Copy link

Choose a reason for hiding this comment

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

Maybe you should consider using equalsIgnoreCase instead


lst.add(new Todo(str));
}
else if((str.split(" ", 2)[0]).equals("deadline")) {
Copy link

Choose a reason for hiding this comment

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

The if here is also missing a space

lst.add(new Deadline(str));
}
else if((str.split(" ", 2)[0]).equals("event")) {
lst.add(new Event(str));
}
else {
throw new InvalidCommandException();
}
int size = lst.size();
System.out.println("Got it. I've added this task:");
System.out.println(" " + lst.get(size-1).toString());
System.out.println("Now you have " + size + " tasks in the list");
}

public static void print_list() {
for(int i = 0; i < lst.size(); i++) {

System.out.println((i+1) + ". " + lst.get(i).toString());
}
}

public static void mark(Task tsk) {
tsk.toggleTrue();
System.out.println("Nice! I've marked this task as done:");
System.out.println(tsk.toString());
}

public static void unmark(Task tsk) {
tsk.toggleFalse();
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(tsk.toString());
}
public static void reply() {
String str = sc.nextLine();
if(str.equals("bye")) {
System.out.println("Bye mortal, I will get back to destroying" +
" galaxies");
}
else if(str.equals("list")) {
print_list();
reply();
}
else if((str.split(" ", 2)[0]).equals("mark")) {
mark(lst.get(Integer.parseInt((str.split(" ", 2)[1])) - 1));
reply();
}
else if((str.split(" ", 2)[0]).equals("unmark")) {
unmark(lst.get(Integer.parseInt((str.split(" ", 2)[1])) - 1));
reply();
}
else if((str.split(" ", 2)[0]).equals("delete")) {
System.out.println("Noted. I've removed this task:");
System.out.println(" " + lst.get(Integer.parseInt((str.split(" ", 2)[1])) - 1).toString());
lst.remove(Integer.parseInt((str.split(" ", 2)[1])) - 1);
System.out.println("Now you have " + lst.size() + " tasks in the list.");
reply();
}
else {
try {
add_to_list(str);
}
catch(InvalidCommandException e) {
System.out.println("the command is invalid");
}
catch(NoDescriptionException e) {
System.out.println("the task needs to have a description");
}
reply();
}
}

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
}
}
String welcome_msg = "Hello my name is Thanos, my hobbies are helping people maintain their schedule and " +
"destroying galaxies.";
System.out.println(welcome_msg);
reply();
}
}
6 changes: 6 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class DukeException extends Exception {
private String message;
public DukeException() {
this.message = "bogus";
}
}
27 changes: 27 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class Event extends Task {

public Event(String str1) {
super(str1);
}

String[] mainSplit = super.task_name.split(" ", 2); //original : "event project meeting /from Mon 2pm /to 4pm"
String name = mainSplit[1]; // gives "project meeting /from Mon 2pm /to 4pm"
String[] StrList1 = name.split(" /from ", 2); //gives ["project meeting","Mon 2pm /to 4pm"]
String nameMain = StrList1[0]; //gives "project meeting"
String[] StrList2 = StrList1[1].split(" /to ", 2); //gives ["Mon 2pm", "to 4pm"]
String frm = StrList2[0]; //gives "Mon 2pm"
String to = StrList2[1]; //gives "to 4pm"

Choose a reason for hiding this comment

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

Perhaps proper naming of variables can help to reduce the number of comments. Maybe consider frm to be renamed to startingTime and to to endingTime.

String finalTime = "from " + frm + " to " + to;


@Override
public String toString() {
if(super.status == true) {
Copy link

Choose a reason for hiding this comment

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

There should be a space between if and (

return "[E][X] " + nameMain + " " + finalTime;
}
else {
return "[E][ ] " + nameMain + " " + finalTime;
}
}

}
5 changes: 5 additions & 0 deletions src/main/java/InvalidCommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class InvalidCommandException extends DukeException{
public InvalidCommandException() {
super();
}
}
5 changes: 5 additions & 0 deletions src/main/java/NoDescriptionException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class NoDescriptionException extends DukeException{
public NoDescriptionException() {
super();
}
}
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 abstract class Task {

public String task_name;
public boolean status;
public Task(String str) {
task_name = str;
status = false;
}

public void toggleTrue() {
status = true;
}

public void toggleFalse() {
status = false;
}
}
21 changes: 21 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class Todo extends Task {

public Todo(String str1) {
super(str1);
}
String[] mainSplit = super.task_name.split(" ", 2);
String name = mainSplit[1];


@Override
public String toString() {
if(super.status == true) {
return "[T][X] " + name;
}
else {
return "[T][ ] " + name;
}
}


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

Hello my name is Thanos, my hobbies are helping people maintain their schedule and destroying galaxies.
Got it. I've added this task:
[T][ ] borrow book
Now you have 1 tasks in the list
Got it. I've added this task:
[D][ ] cry about my cap (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
Nice! I've marked this task as done:
[D][X] cry about my cap (by: Sunday)
Nice! I've marked this task as done:
[T][X] borrow book
Got it. I've added this task:
[T][ ] eat popcorn
Now you have 4 tasks in the list
1. [T][X] borrow book
2. [D][X] cry about my cap (by: Sunday)
3. [E][ ] project meeting from Mon 2pm to 4pm\
4. [T][ ] eat popcorn
OK, I've marked this task as not done yet:
[T][ ] borrow book
Bye mortal, I will get back to destroying galaxies
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 @@
todo borrow book
deadline cry about my cap /by Sunday
event project meeting /from Mon 2pm /to 4pm\
mark 2
mark 1
todo eat popcorn
list
unmark 1
bye