Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
a4564e4
rename "Duke" to "Luke", and added greetings
janelleenqi Sep 4, 2023
860d878
add echo feature
janelleenqi Sep 4, 2023
35b72fc
add features (add, list but reverse)
janelleenqi Sep 5, 2023
5fc8ba6
amend features (add, list)
janelleenqi Sep 5, 2023
8e02823
add feature (mark as done)
janelleenqi Sep 5, 2023
6b19f57
tweaks to follow naming conventions
janelleenqi Sep 5, 2023
aebc096
Added three different task types (ToDos, Events, Deadlines)
janelleenqi Sep 7, 2023
17570b2
Added three different task types (ToDos, Events, Deadlines)
janelleenqi Sep 7, 2023
10bcaae
Added three different task types (ToDos, Events, Deadlines)
janelleenqi Sep 7, 2023
b503333
Added three different task types (ToDos, Events, Deadlines)
janelleenqi Sep 7, 2023
5bae015
Added Text-UI-Testing
janelleenqi Sep 7, 2023
2702b6e
Revise formatting, Implement enum & switch
janelleenqi Sep 10, 2023
7796691
make Task an abstract task
janelleenqi Sep 17, 2023
39b457c
fix lines spaced part 2
janelleenqi Sep 17, 2023
573e246
fix lines spaced part 2
janelleenqi Sep 17, 2023
bf1f72b
remove unnecessary line
janelleenqi Sep 19, 2023
7087e36
IntelliJ recommendations
janelleenqi Sep 19, 2023
0609792
add some try-catch blocks
janelleenqi Sep 19, 2023
e41f732
add some try-catch blocks and throw-catch blocks
janelleenqi Sep 20, 2023
6c7aeb7
add try-catch blocks and throw-catch blocks for random words
janelleenqi Sep 20, 2023
4320721
change to more specific error message lines
janelleenqi Sep 20, 2023
f6e4a2d
change to even more specific error message lines and fix list error
janelleenqi Sep 20, 2023
5dc30d9
throw error if deadline format is wrong
janelleenqi Sep 20, 2023
e0a2e01
throw error if event format is wrong
janelleenqi Sep 20, 2023
3eb76bc
Merge branch 'branch-Level-5'
janelleenqi Sep 20, 2023
25200f0
divide classes into packages
janelleenqi Sep 20, 2023
746312f
fix lines
janelleenqi Sep 20, 2023
37b5bb1
Merge branch 'branch-A-packages'
janelleenqi Sep 20, 2023
ed9f860
use java collection classes, add "delete" action
janelleenqi Sep 21, 2023
022d97d
(notes: errors exist) adding memory storage using txt file
janelleenqi Sep 21, 2023
e51e000
ignore META-INF folder
janelleenqi Sep 21, 2023
36fcba8
write new memory into memory.txt, ignore META-INF folder
janelleenqi Sep 21, 2023
0641727
ignore META-INF folder
janelleenqi Sep 21, 2023
af7f54c
(still needs fixing) add read ability from existing file
janelleenqi Sep 21, 2023
0437cfb
(still needs fixing) able to read from file and write to file but una…
janelleenqi Sep 21, 2023
6494a32
.gitignore for memory.txt
janelleenqi Sep 21, 2023
52f898d
Merge branch 'branch-Level-6'
janelleenqi Sep 21, 2023
39ad792
resolved conflicts (same errors of can read, can write, but cannot us…
janelleenqi Sep 21, 2023
652c9b2
can use file data
janelleenqi Sep 21, 2023
51f7a9f
fix indentation
janelleenqi Oct 4, 2023
4bcd01d
fix indentation
janelleenqi Oct 4, 2023
801ed78
Add "find" ActionType
janelleenqi Oct 4, 2023
39eda3c
Add Objects (Ui & Parser)
janelleenqi Oct 5, 2023
18a6643
Add Objects (ExitCommand)
janelleenqi Oct 5, 2023
bf62341
Add Objects (DeleteCommand)
janelleenqi Oct 5, 2023
56321ce
Add Objects (ListCommand)
janelleenqi Oct 5, 2023
48815a3
Add Objects (FindCommand)
janelleenqi Oct 5, 2023
ef5a710
make more OOP but with errors
janelleenqi Oct 5, 2023
2da6307
Add Objects (MarkCommand)
janelleenqi Oct 5, 2023
49d2924
Fix Objects (Parser), to include instantiating child classes of Command
janelleenqi Oct 5, 2023
772d5cf
Add Objects (AddCommand)
janelleenqi Oct 5, 2023
f1b66a6
Add Abstract Class (Command)
janelleenqi Oct 5, 2023
364d48d
Fix Objects (Parser)
janelleenqi Oct 5, 2023
ad80c66
Add Objects (Storage)
janelleenqi Oct 5, 2023
1818f2f
Add Objects (TaskList)
janelleenqi Oct 5, 2023
3190778
Fix Objects (Ui)
janelleenqi Oct 5, 2023
b99923f
Fix Luke to get a code that can run
janelleenqi Oct 5, 2023
1109f04
Add "BYE" to ActionType, Add "BYE" case to Parser parse method, so th…
janelleenqi Oct 5, 2023
3ad68bf
Fix small errors
janelleenqi Oct 5, 2023
de661a4
Fix - "bye" ends Luke without scanner errors
janelleenqi Oct 5, 2023
a466466
Fix Retrieval of Memory (syntax)
janelleenqi Oct 5, 2023
4342a65
Print correct and specific error messages for errors
janelleenqi Oct 5, 2023
698d964
Fix spacing in memory storage/retrieval
janelleenqi Oct 5, 2023
41f428d
Code Organisation
janelleenqi Oct 5, 2023
3d28a78
Merge branch 'branch-A-MoreOOP'
janelleenqi Oct 5, 2023
b8fe251
Add JavaDoc comments
janelleenqi Oct 5, 2023
54c9b4c
Fix Level-9
janelleenqi Oct 5, 2023
afa9433
Merge pull request #1 from janelleenqi/branch-Level-9
janelleenqi Oct 5, 2023
3d45534
Merge branch 'master' into branch-A-JavaDoc
janelleenqi Oct 5, 2023
1845d33
Merge pull request #2 from janelleenqi/branch-A-JavaDoc
janelleenqi Oct 5, 2023
56970bd
Update docs\README.md
janelleenqi Oct 5, 2023
688c7da
Update docs\README.md part 2
janelleenqi Oct 5, 2023
3ed4739
Update docs\README.md part 3
janelleenqi Oct 6, 2023
a1a0256
Update docs\README.md part 4
janelleenqi Oct 6, 2023
f21791f
Update Level 7 Save: Luke runs even if no memory.txt exists
janelleenqi Oct 6, 2023
e1e19fb
Update Level 7 Save: Luke runs even if no memory.txt exists part 2
janelleenqi Oct 6, 2023
5c566bd
Update Level 7 Save: directory "data" is created and file "memory.txt…
janelleenqi Oct 6, 2023
2e094bf
Rename LukeTimeError to LukeException
janelleenqi Oct 6, 2023
4e9d393
Refine error from invalid user input
janelleenqi Oct 6, 2023
05973a4
Catch NumberFormatException errors for delete, mark and unmark
janelleenqi Oct 6, 2023
2294806
Refine error messages
janelleenqi Oct 6, 2023
bfe863a
Add user guide within Luke application
janelleenqi Oct 6, 2023
bef32d4
Edit JavaDoc Comments
janelleenqi Oct 6, 2023
bd4a715
Minor Edit
janelleenqi Oct 6, 2023
e27b225
Fix Memory Saving for Task Completion Status
janelleenqi Oct 6, 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
3 changes: 3 additions & 0 deletions src/main/java/ActionType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public enum ActionType {
LIST, MARK, UNMARK, TODO, DEADLINE, EVENT
}
31 changes: 31 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public class Deadline extends Todo {
protected String byDate;

public Deadline(String description, String date) {
super(description);
setByDate(date);
}

public String getByDate() {
return byDate;
}

public void setByDate(String date) {
int spaceCut = date.indexOf(" ");
byDate = date.substring(spaceCut + 1);
}

@Override
public String toString() {
//super.toString();
String isDoneString;

if (isDone()) {
isDoneString = "[X]";
} else {
isDoneString = "[ ]";
}

return "\t[D]" + isDoneString + getDescription() + "(do by: " + getByDate() + ")";
}
}
96 changes: 90 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,94 @@
import java.util.Scanner;

public class Duke {
private static final String BYE_COMMAND = "bye";
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String logo = "\t _ _\n"
+ "\t| | _ _| | _____\n"
+ "\t| | | | | | |/ / _ \\\n"
+ "\t| |___| |_| | < __/\n"
+ "\t|_____|\\__,_|_|\\_\\___|\n";
System.out.println("\t" + "Hello! I'm\n" + logo);
System.out.println("\t" + "What can I do for you?");

Task[] taskList = new Task[100];
Scanner userInput = new Scanner(System.in);
int counter = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps the counter variable could be more descriptive to allow the reader to understand what it is counting.


String echo = userInput.nextLine();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can consider making some changes to the following variables:

  • echo should be renamed to userInputString instead since your default command is now adding a new task
  • userInput should contain the scanner keyword such as inputScanner to better signify that it is the scanner object

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider using a more suitable name for echo so that it is more descriptive for the reader.

int taskNumber;
String taskDescription;
int slashCut;

while (!echo.equals(BYE_COMMAND)) {
String[] words = echo.split(" "); //to identify usage of features "mark" & "unmark"
ActionType action = ActionType.valueOf(words[0].toUpperCase());

switch (action) {
case LIST:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is a violation of Java coding standard here. There should be no indentation for case clauses. Please configure your IDE to follow the coding standard.

System.out.println("\tHere are the tasks in your list:");
for (int i = 0; i < counter; i += 1) {
System.out.println("\t" + (i + 1) + "." + taskList[i]);
}
break;
case MARK:
taskNumber = Integer.parseInt(words[1]) - 1;
System.out.println("\tWoohoo! You have accomplished:");
taskList[taskNumber].setDone(true);
System.out.println(taskList[taskNumber]);
break;
case UNMARK:
taskNumber = Integer.parseInt(words[1]) - 1;
System.out.println("\tHA! You still have to complete:");
taskList[taskNumber].setDone(false);
System.out.println(taskList[taskNumber]);
break;

case TODO:
//int spaceCut = echo.indexOf(" ");
taskDescription = echo.substring(4);
taskList[counter] = new Todo(taskDescription);
System.out.println("\tGot it. I've added this task:" + "\n" + taskList[counter]);
counter += 1;
System.out.println("\tNow you have " + counter + " tasks in the list.");
break;


case DEADLINE:
taskDescription = echo.substring(8);
slashCut = taskDescription.indexOf("/");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider renaming this variable to make it more descriptive.


String taskDeadline = taskDescription.substring(slashCut + 1);
taskDescription = taskDescription.substring(0, slashCut);

taskList[counter] = new Deadline(taskDescription, taskDeadline);
System.out.println("\tGot it. I've added this task:" + "\n" + taskList[counter]);
counter += 1;
System.out.println("\tNow you have " + counter + " tasks in the list.");
break;


case EVENT:
taskDescription = echo.substring(5);
slashCut = taskDescription.indexOf("/");

String taskDuration = taskDescription.substring(slashCut);
taskDescription = taskDescription.substring(0, slashCut);

taskList[counter] = new Event(taskDescription, taskDuration);
System.out.println("\tGot it. I've added this task:" + "\n" + taskList[counter]);
counter += 1;
System.out.println("\tNow you have " + counter + " tasks in the list.");
break;

default:
break;
}
echo = userInput.nextLine();
}

System.out.println("\tBye. Hope to see you again soon!");

userInput.close();
}
}
43 changes: 43 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
public class Event extends Deadline {
protected String startDate;
protected String endDate;

public Event(String description, String dates) {
super(description, dates);
setDates(dates);
}

public String getStartDate() {
return startDate;
}

public String getEndDate() {
return endDate;
}

public void setDates(String dates) {
int spaceCut = dates.indexOf(" ");
dates = dates.substring(spaceCut + 1);

int slashCut = dates.indexOf("/");
startDate = dates.substring(0, slashCut);
dates = dates.substring(slashCut + 1);

spaceCut = dates.indexOf(" ");
endDate = dates.substring(spaceCut + 1);
}

@Override
public String toString() {
//super.toString();
String isDoneString;

if (isDone()) {
isDoneString = "[X]";
} else {
isDoneString = "[ ]";
}

return "\t[E]" + isDoneString + getDescription() + "(from: " + getStartDate() + "to: " + getEndDate() + ")";
}
}
28 changes: 28 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class Task {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job for using good coding standards in this file! Descriptive names are used for functions and variables

protected String description;
protected boolean isDone;

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

public String getDescription() {
return description;
}


public boolean isDone() {
return isDone;
}

public void setDone(boolean done) {
isDone = done;
}

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

}
22 changes: 22 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
public class Todo extends Task {
//protected boolean isDone;

public Todo(String description) {
super(description);
//isDone = false;
}

@Override
public String toString() {
//super.toString();
String isDoneString;

if (isDone()) {
isDoneString = "[X]";
} else {
isDoneString = "[ ]";
}

return "\t[T]" + isDoneString + getDescription();
}
}
32 changes: 26 additions & 6 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
Hello! I'm
_ _
| | _ _| | _____
| | | | | | |/ / _ \
| |___| |_| | < __/
|_____|\__,_|_|\_\___|

What can I do for you?
Got it. I've added this task:
[T][ ] Liow Enqi Janelle Answer CS2113 tutorial questions
Now you have 1 tasks in the list.
Got it. I've added this task:
[D][ ] weekly CS2113 quiz (do by: Monday 9pm)
Now you have 2 tasks in the list.
Here are the tasks in your list:
1.[T][ ] Liow Enqi Janelle Answer CS2113 tutorial questions
2.[D][ ] weekly CS2113 quiz (do by: Monday 9pm)
Got it. I've added this task:
[E][ ] CS2113 lecture (from: Friday 4 to: 6pm)
Now you have 3 tasks in the list.
Woohoo! You have accomplished:
[T][X] Liow Enqi Janelle Answer CS2113 tutorial questions
Here are the tasks in your list:
1.[T][X] Liow Enqi Janelle Answer CS2113 tutorial questions
2.[D][ ] weekly CS2113 quiz (do by: Monday 9pm)
3.[E][ ] CS2113 lecture (from: Friday 4 to: 6pm)
Bye. Hope to see you again soon!
7 changes: 7 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
todo Liow Enqi Janelle Answer CS2113 tutorial questions
deadline weekly CS2113 quiz /by Monday 9pm
list
event CS2113 lecture /from Friday 4 /to 6pm
mark 1
list
bye
9 changes: 5 additions & 4 deletions text-ui-test/runtest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash


# create bin directory if it doesn't exist
if [ ! -d "../bin" ]
then
Expand All @@ -13,7 +14,7 @@ then
fi

# compile the code into the bin folder, terminates if error occurred
if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/*.java
if ! javac -cp /Users/janelle/cs2113repo/ip/src/main/java -Xlint:none -d ../bin /Users/janelle/cs2113repo/ip/src/main/java/*.java
then
echo "********** BUILD FAILURE **********"
exit 1
Expand All @@ -23,11 +24,11 @@ fi
java -classpath ../bin Duke < input.txt > ACTUAL.TXT

# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT
dos2unix ACTUAL.TXT EXPECTED-UNIX.TXT
#cp EXPECTED.TXT EXPECTED-UNIX.TXT
#dos2unix ACTUAL.TXT EXPECTED-UNIX.TXT

# compare the output to the expected output
diff ACTUAL.TXT EXPECTED-UNIX.TXT
diff ACTUAL.TXT EXPECTED.TXT
if [ $? -eq 0 ]
then
echo "Test result: PASSED"
Expand Down