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

[SaiChaitanya13] ip #203

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
cbe03ba
Added Increment - Level 0
Jan 28, 2023
f2d0bfe
Added Increment - Level 1
Jan 28, 2023
e5f9282
Added Increment - Level 2
Jan 28, 2023
c0efa6e
Added Increment - Level 3
Jan 31, 2023
eae4525
Coding Standards --> Used camelCase throughout
Jan 31, 2023
7435c1a
Added Increment - Level 4
Jan 31, 2023
8c9d925
Cleaned up code + Added increment - Code Quality
Feb 9, 2023
4a3350e
Cleaned up code + Added increment - Code Quality
Feb 9, 2023
8bf9626
Improved code quality
Feb 9, 2023
8e63c8d
Added Level 5 for two exceptions + reformatted code
Feb 10, 2023
63a70ee
Added exceptions for Level 5
Feb 10, 2023
7d9c743
Merge branch 'branch-Level-5'
Feb 10, 2023
cc2f69d
add delete command
Feb 17, 2023
1f72f15
add delete command
Feb 17, 2023
6d07cfd
Changed to array list + Added Level 6
Feb 19, 2023
8c7e7a7
refactored code
Feb 20, 2023
a969961
added Storage
Feb 28, 2023
f8c9289
resolve merge conflicts
Feb 28, 2023
5fe1586
add delete command
Feb 17, 2023
9c94db0
add delete command
Feb 17, 2023
cca8512
Changed to array list + Added Level 6
Feb 19, 2023
8d246b7
refactored code
Feb 20, 2023
a9ef0bd
Merge branch 'branch-Level-6'
Feb 28, 2023
678f733
delete branch 7 to make it easier
Feb 28, 2023
154b006
Done till Level 6
Feb 28, 2023
a6e5092
Testing
Mar 1, 2023
9fb485f
Merge branch 'master' of https://github.com/SaiChaitanya13/ip
Mar 1, 2023
34f8b0d
SAVE FINALLY WORKS WOHOO
Mar 2, 2023
5d87d90
Merge branch 'branch-Level-7'
Mar 2, 2023
91858cb
Working JAR File
Mar 2, 2023
b7593c6
Working JAR File
Mar 2, 2023
5c84e0b
FIND function implemented
Mar 2, 2023
d69ac7a
Merge branch 'branch-Level-9'
Mar 2, 2023
999cf72
Added Task List Class which works!!
Mar 2, 2023
8a086b7
Added the different Task Command Classes
Mar 2, 2023
df06edd
Added ALL Command classes - Task and Action
Mar 2, 2023
511e48c
Added Parser Class and works
Mar 2, 2023
4c43b1e
Added Messages Class
Mar 2, 2023
8f0a3e8
Added Help Command and Help Message
Mar 2, 2023
5c3cb49
Added Greeting
Mar 2, 2023
5bebd19
Add Date Time Formatter for Deadline
Mar 2, 2023
de0616c
changing just to merge
Mar 2, 2023
1dd986b
Merge branch 'branch-Level-8'
Mar 2, 2023
bb101ad
Added exceptions to code
Mar 2, 2023
7b4656e
merge conflicts resolved
Mar 2, 2023
e45aba2
Added Testing
Mar 2, 2023
8ca8fd8
All works, adding UI
Mar 3, 2023
3ffea71
Added MoreOOP everything works
Mar 3, 2023
2675b55
added to main, debugging issues
Mar 3, 2023
39a3bfb
file works WITHOUT directory
Mar 3, 2023
856052c
imported packages without * so better coding standard
Mar 3, 2023
e444e1b
LETS GO Storage Path changed with directory AND IT WORKS!
Mar 3, 2023
acc7aea
minor reformatting of code
Mar 3, 2023
beb0c51
Made minor documentation
Mar 3, 2023
8cc346b
Added ALL Documentation in the right format
Mar 3, 2023
a3f035e
Merge branch 'branch-A-JavaDoc'
Mar 3, 2023
c2fc057
Reformatted code and added in some additional checks
Mar 3, 2023
9aff198
Fixed many bugs
Mar 3, 2023
15e388b
Added User Guide
Mar 3, 2023
cb8a6f0
FINAL CHANGES FINALISED BUDDY YAY
Mar 3, 2023
0a0118e
slight change
Mar 3, 2023
57d9fcb
small change for merge
Mar 3, 2023
3be8a94
Merge pull request #1 from SaiChaitanya13/mergepr
SaiChaitanya13 Mar 3, 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
127 changes: 127 additions & 0 deletions src/main/java/Buddy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import java.util.Scanner;
import java.util.Arrays;

// camelCase used as a coding standard
// indented according to Java coding standards

public class Buddy {

static final int TOTAL_TASKS = 100;

public static void main(String[] args) {
Copy link

Choose a reason for hiding this comment

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

too much happening in main, try to refactor to improve readibility and abstraction

String greeting = "Hello there! I'm Buddy\n"
+ "How may I assist you?";
String listOfCommands = "Here are the commands you can use: todo, deadline, event, list, mark, unmark, bye";
String exitMessage = "Hope I was of help to you! Have a great day and see you again, Buddy :)";
String divider = "________________________________________________________________________________";

System.out.println(divider);
System.out.println(greeting);
System.out.println(listOfCommands);
System.out.println(divider);

Task[] listOfThings = new Task[TOTAL_TASKS]; // why cannot private static?
int currentPosition = 0; // why cannot private static?
Copy link

Choose a reason for hiding this comment

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

don't leave comments for yourself in the code

String command;
Scanner in = new Scanner(System.in);
command = in.nextLine();


while (!command.equals("bye")) {

int index = 1;
if (command.equals("list")) {
for (int i = 0; i < currentPosition; i++) { // while not null
System.out.println(index + "." + listOfThings[index - 1]);
index++;
}
} else if (command.startsWith("mark")) { // .startsWith(" ")
int taskNumberIndexMark = 5;
int taskNumber = Integer.parseInt(command.substring(taskNumberIndexMark));
// have to parse

try {
Task currentTask = listOfThings[taskNumber - 1];
currentTask.setDone(true);
System.out.println(divider);
System.out.println("Great work on completing this task! Marked as done! :)");
System.out.println(currentTask);
System.out.println(divider);
} catch (IndexOutOfBoundsException a) {
System.out.println("That is not a valid task to mark! Please check your list again and input a valid task");

}
} else if (command.startsWith("unmark")) {
int taskNumberIndexUnmark = 7;
int taskNumber = Integer.parseInt(command.substring(taskNumberIndexUnmark));

try {
Task currentTask = listOfThings[taskNumber - 1];

currentTask.setDone(false);
System.out.println(divider);
System.out.println("Remember to come back to this task! Marked as undone!");
System.out.println(currentTask);
System.out.println(divider);
} catch (IndexOutOfBoundsException a) {
System.out.println("That is not a valid task to unmark! Please check your list again and input a valid task");

}
} else if (command.startsWith("todo") || command.startsWith("deadline") || command.startsWith("event")) { //todo or deadline or event --> put together so don't have to repeat the same code thrice
System.out.println(divider);
System.out.println("Got it! I have added this task: ");
if (command.startsWith("todo")) {
int todoStartingIndex = 5;

Todo todoBeingAdded = new Todo(command.substring(todoStartingIndex));
listOfThings[currentPosition] = todoBeingAdded;

// Task is not a Todo but Todo is a task
System.out.println(todoBeingAdded);

} else if (command.startsWith("deadline")) {
int deadlineStartingIndex = 9;
Task taskBeingAdded = new Task(command.substring(deadlineStartingIndex)); // task + date + slash (Description)
// filter the description and date
Copy link

Choose a reason for hiding this comment

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

I like the use of comments to explain the code when needed.

String taskWithDate = taskBeingAdded.description;
Copy link

Choose a reason for hiding this comment

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

Clear variable names that are easy to understand

int indexOfSlash = taskWithDate.indexOf('/');
String taskDescription = taskWithDate.substring(0, (indexOfSlash - 1)); // substring goes to the one before the second index!!!!

Choose a reason for hiding this comment

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

Perhaps it might be good to indent the multiple line comments to be aligned with the block?

String date = taskWithDate.substring(indexOfSlash + 4);
Deadline deadlineBeingAdded = new Deadline(taskDescription, date);
listOfThings[currentPosition] = deadlineBeingAdded;
System.out.println(deadlineBeingAdded);

} else if (command.startsWith("event")) {
int eventStartingIndex = 6;
Task taskBeingAdded = new Task(command.substring(eventStartingIndex));
// filter the description, from and to
String wholeLine = taskBeingAdded.description;
int indexOfFirstSlash = wholeLine.indexOf('/');
String taskDescription = wholeLine.substring(0, (indexOfFirstSlash - 1));
int indexOfSecondSlash = wholeLine.indexOf('/', (indexOfFirstSlash + 1)); //searches from index after first slash
String from = wholeLine.substring((indexOfFirstSlash + 6), (indexOfSecondSlash));
String to = wholeLine.substring(indexOfSecondSlash + 4);
Event eventBeingAdded = new Event(taskDescription, from, to);
listOfThings[currentPosition] = eventBeingAdded;
System.out.println(eventBeingAdded);
}

currentPosition++;
System.out.print("You currently have " + currentPosition);
if (currentPosition == 1) {
System.out.println(" task remaining! Let's finish it quickly!");
} else {
System.out.println(" tasks remaining! You got this, buddy!"); // all these same for all three subtasks so put at the bottom
}
} else {
System.out.println("This command does not exist! Please type a valid command!");
}
command = in.nextLine();

}
System.out.println(divider);
System.out.println(exitMessage);
System.out.println(divider);

}
}
2 changes: 2 additions & 0 deletions src/main/java/BuddyException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public class BuddyException {
}
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 {

protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}

@Override
public String toString() {
return "[D]" + super.toString() + " (Please do by: " + by + "!)";
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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

protected String from;
protected String to;

public Event(String description, String from, String to) {
super(description);
this.from = from;
this.to = to;
}

@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + from + "to: " + to + ")";
}
}
26 changes: 26 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
public class Task {
protected String description;
protected boolean isDone; // protected => public

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

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}

public boolean isDone() { // do we need this
Copy link

Choose a reason for hiding this comment

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

use action naming for method

return isDone;
}

public void setDone(boolean isDone) {
this.isDone = isDone;
}

@Override // overrides --> print task prints this!
public String toString() {
return "[" + this.getStatusIcon() + "] " + this.description;
}
}
12 changes: 12 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class Todo extends Task {
protected boolean isDone;
public Todo(String description) {
super(description); // don't need isDone as isDone is already in Task class
}

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