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

[Rama Venkatesh] iP #503

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
a5e37a0
Level-1
ramaven Aug 19, 2021
9f114de
Level-2
ramaven Aug 19, 2021
254a843
Level-3
ramaven Aug 19, 2021
dcbae92
Level-4
ramaven Aug 19, 2021
cba3a3a
Level-5
ramaven Aug 19, 2021
ec3c11f
Level-6
ramaven Aug 19, 2021
913b02f
modified expected output
ramaven Sep 2, 2021
75ec70d
enum & refactoring
ramaven Sep 2, 2021
76f877c
enum; refactoring
ramaven Sep 2, 2021
d6610f1
added save functionality
ramaven Sep 5, 2021
6e00451
added save
ramaven Sep 5, 2021
a4d5124
Added DukeDate parse
ramaven Sep 6, 2021
98be0ed
Merge branch 'master' into branch-Level-8
ramaven Sep 6, 2021
bb01e2e
Merge pull request #1 from ramaven/branch-Level-8
ramaven Sep 6, 2021
f54b7d8
fixed getDate() bug
ramaven Sep 6, 2021
6e50441
refactored packages
ramaven Sep 6, 2021
54125a4
removed debug statements
ramaven Sep 6, 2021
c471774
added Command class; OOP
ramaven Sep 6, 2021
b330b0d
adhered coding standard
ramaven Sep 11, 2021
35c0733
adhered coding standard
ramaven Sep 11, 2021
49b8c33
added javadocs
ramaven Sep 11, 2021
a5955e0
added find functionality
ramaven Sep 11, 2021
0dd98f3
Merge pull request #2 from ramaven/branch-A-CodingStandard
ramaven Sep 11, 2021
deafde9
Merge pull request #3 from ramaven/branch-A-JavaDoc
ramaven Sep 11, 2021
80d6917
Merge pull request #4 from ramaven/branch-Level-9
ramaven Sep 11, 2021
84bc195
Merge pull request #6 from ramaven/add-gradle-support
ramaven Sep 12, 2021
f1722c7
fixed file save bug
ramaven Sep 12, 2021
90738d5
fixed file save bug
ramaven Sep 12, 2021
8c536cb
added gradle support
ramaven Sep 12, 2021
1848605
Merge branch 'master' into branch-A-Gradle
ramaven Sep 12, 2021
6657c54
Merge pull request #7 from ramaven/branch-A-Gradle
ramaven Sep 12, 2021
d183176
checkstyle
ramaven Sep 12, 2021
559aa07
Merge pull request #8 from ramaven/branch-A-Checkstyle
ramaven Sep 12, 2021
6137ed5
modified gradle build file
ramaven Sep 12, 2021
99eeead
Merge branch 'master' into branch-A-Checkstyle
ramaven Sep 12, 2021
0dc6f8e
Merge pull request #9 from ramaven/branch-A-Checkstyle
ramaven Sep 12, 2021
48c8b01
Added GUI
ramaven Sep 13, 2021
6f08fb4
Merge pull request #10 from ramaven/branch-Level-10
ramaven Sep 13, 2021
a6c7cec
Add assert statements
ramaven Sep 14, 2021
431ad92
Merge pull request #11 from ramaven/branch-A-Assertions
ramaven Sep 14, 2021
b919c18
Find command: make matching case insensitive
ramaven Sep 14, 2021
23b81b1
Merge pull request #12 from ramaven/branch-C-BetterSearch
ramaven Sep 14, 2021
6735ff4
Improve code quality
ramaven Sep 15, 2021
85deaac
Merge pull request #13 from ramaven/branch-A-CodeQuality
ramaven Sep 15, 2021
375ee70
Add product screenshot
ramaven Sep 15, 2021
5db5d46
Add user guide
ramaven Sep 15, 2021
790acc6
Set theme jekyll-theme-minimal
ramaven Sep 15, 2021
b5d33a9
Set theme jekyll-theme-leap-day
ramaven Sep 15, 2021
1e5ca13
Edit User Guide
ramaven Sep 15, 2021
0557aa0
Merge branch 'master' of https://github.com/ramaven/ip
ramaven Sep 15, 2021
855c0ad
Update README
ramaven Sep 15, 2021
dc82355
Update README.md
ramaven Sep 15, 2021
27a3096
Update README.md
ramaven Sep 15, 2021
f17b05f
Update README.md
ramaven Sep 15, 2021
a9ce5a5
Add credits
ramaven Sep 15, 2021
979f83f
Improve code quality
ramaven Sep 15, 2021
8e8c1d7
Add test methods
ramaven Sep 17, 2021
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
88 changes: 87 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,96 @@
import tasks.*;
import exceptions.*;

Choose a reason for hiding this comment

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

Maybe can name out all the files that you are importing instead of using a wildcard?

import java.util.ArrayList;
import java.util.Scanner;

public class Duke {
public static void main(String[] args) {
public static void main(String[] args) throws DukeException{
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

System.out.println("Hello! I'm Duke \nWhat can I do for you?");

Scanner sc = new Scanner(System.in);

//Task[] tasks = new Task[100];
ArrayList<Task> tasks = new ArrayList<Task>();
int taskCounter = 0;

String input = "";
try {while(true){

Choose a reason for hiding this comment

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

Suggested change
try {while(true){
try {
while(true) {

input = sc.nextLine();
if(input.equals("bye")){

Choose a reason for hiding this comment

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

Suggested change
if(input.equals("bye")){
if(input.equals("bye")) {

System.out.println("Bye. Hope to see you again soon!\n");
break;
//System.exit();
}
else if(input.equals("list")) {

Choose a reason for hiding this comment

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

Suggested change
else if(input.equals("list")) {
else if (input.equals("list")) {

for(int i = 0; i < taskCounter; i++){
System.out.println((i+1) + "." + tasks.get(i).toString());
}
} else if (input.length() > 4 && input.substring(0,4).equals("done")){

Choose a reason for hiding this comment

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

Suggested change
} else if (input.length() > 4 && input.substring(0,4).equals("done")){
} else if (input.length() > 4 && input.substring(0,4).equals("done")) {

String taskDone = input.substring(5);
int taskDoneIndex = Integer.parseInt(taskDone)-1;

Choose a reason for hiding this comment

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

Suggested change
int taskDoneIndex = Integer.parseInt(taskDone)-1;
int taskDoneIndex = Integer.parseInt(taskDone) - 1;

tasks.get(taskDoneIndex).makeDone();
System.out.println("Nice! I've marked this task as done: ");
System.out.println(tasks.get(taskDoneIndex).toString());
}
else {
if(input.length()<4 ){

Choose a reason for hiding this comment

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

Suggested change
if(input.length()<4 ){
if (input.length() < 4) {

throw new DukeException("Unacceptable input");
}
if(input.substring(0,4).equals("todo")){

Choose a reason for hiding this comment

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

Suggested change
if(input.substring(0,4).equals("todo")){
if(input.substring(0,4).equals("todo")) {

TodoTask newTask = new TodoTask(input.substring(5));
tasks.add(newTask);
taskCounter++;
System.out.println("Got it. I've added this task: ");
System.out.print(" " + newTask.toString());

} else if(input.substring(0,5).equals("event")){

Choose a reason for hiding this comment

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

Suggested change
} else if(input.substring(0,5).equals("event")){
} else if(input.substring(0,5).equals("event")) {

String at = input.split("/")[1].substring(3);
EventTask newEvent = new EventTask(input.substring(6).split("/")[0], at);
tasks.add(newEvent);
taskCounter++;
System.out.println("Got it. I've added this task: ");
System.out.println(" " + newEvent.toString());
} else if(input.length()>5 && input.length()<8){

Choose a reason for hiding this comment

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

Suggested change
} else if(input.length()>5 && input.length()<8){
} else if (input.length() > 5 && input.length() < 8) {

throw new DukeException("Unacceptable input");
}
else if(input.substring(0,6).equals("delete")) {

Choose a reason for hiding this comment

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

Suggested change
else if(input.substring(0,6).equals("delete")) {
else if (input.substring(0,6).equals("delete")) {

// delete from arraylist
// reduce counter by 1
int indexToDel = Integer.parseInt(input.substring(7));
Task tasktoDel = tasks.get(indexToDel);
tasks.remove(indexToDel);
taskCounter--;
System.out.println(" Noted. I've removed this task: ");
System.out.println(" " + tasktoDel.toString());
}
else if(input.substring(0,8).equals("deadline")){

Choose a reason for hiding this comment

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

Suggested change
else if(input.substring(0,8).equals("deadline")){
else if(input.substring(0,8).equals("deadline")) {

// deadline
String by = input.split("/")[1].substring(3);
DeadlineTask newDeadline = new DeadlineTask(input.substring(9).split("/")[0], by);
tasks.add(newDeadline);
taskCounter++;
System.out.println("Got it. I've added this task: ");
System.out.println(" " + newDeadline.toString());

}

else {
throw new DukeException("Unacceptable input");
}

System.out.println("\nNow you have " + (taskCounter) + " tasks in the list.");
}
}} catch (DukeException e){
System.out.println("OOPS!!! You have enteted an invalid category");
}

Choose a reason for hiding this comment

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

I think can format the curly braces better?


}
}

18 changes: 18 additions & 0 deletions src/main/java/Tasks/DeadlineTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package tasks;

public class DeadlineTask extends Task{
String by;
public DeadlineTask(String description, String by) {
super(description, TaskType.DEADLINE);
this.by = by;
}

@Override
public String toString(){

Choose a reason for hiding this comment

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

public String toString() {

String typeString = type == TaskType.TODO ? "T" : type == TaskType.EVENT? "E" : "D";
String doneSymbol = isDone? "X" : " ";

Choose a reason for hiding this comment

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

String doneSymbol = isDone ? "X" : " ";

String result = "[" + typeString + "] " + "[" + doneSymbol + "] " + name + "(by: " + by + ")";
return result;
}

}
17 changes: 17 additions & 0 deletions src/main/java/Tasks/EventTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package tasks;

public class EventTask extends Task {
String at;
public EventTask(String description, String at) {
super(description, TaskType.EVENT);
this.at = at;
}

@Override
public String toString(){
String typeString = type == TaskType.TODO ? "T" : type == TaskType.EVENT? "E" : "D";
String doneSymbol = isDone? "X" : " ";

Choose a reason for hiding this comment

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

String doneSymbol = isDone ? "X" : " ";

String result = "[" + typeString + "] " + "[" + doneSymbol + "] " + name + "(at: " + at + ")";
return result;
}
}
33 changes: 33 additions & 0 deletions src/main/java/Tasks/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package tasks;

public class Task {

protected String name;
protected boolean isDone = false;
TaskType type;

public enum TaskType {
TODO, DEADLINE, EVENT
}

public Task(String name, TaskType type) {
this.name = name;
this.type = type;
}

public boolean isDone(){
return isDone;
}
public void makeDone(){
isDone = true;
}

@Override
public String toString(){
String typeString = type == TaskType.TODO ? "T" : type == TaskType.EVENT? "E" : "D";
String doneSymbol = isDone? "X" : " ";
String result = "[" + typeString + "] " + "[" + doneSymbol + "] " + name;
return result;
}

}
9 changes: 9 additions & 0 deletions src/main/java/Tasks/TodoTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tasks;

public class TodoTask extends Task{

public TodoTask(String description) {
super(description, TaskType.TODO);
}

}
7 changes: 7 additions & 0 deletions src/main/java/exceptions/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package exceptions;

public class DukeException extends Exception {
public DukeException(String message){
super(message);
}
}
2 changes: 2 additions & 0 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Hello from
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

Hello! I'm Duke
What can I do for you?