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

[Rena] iP #458

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
55f9f9f
docs/README.md: Tweak document template
Jan 7, 2024
f837ddb
Add Gradle support
May 24, 2020
a6f7324
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
e038c80
Level 0-1
Chiarena Jan 30, 2024
ec99ab5
Level 1-2
Chiarena Jan 30, 2024
8bf1856
level 2 done
Chiarena Jan 30, 2024
0b4044d
Added level 3
Chiarena Jan 31, 2024
bfe14f0
Added level 4 - deadline,todo,event
Chiarena Jan 31, 2024
beff8a4
added functions
Chiarena Feb 1, 2024
3103d89
Automated testing done
Chiarena Feb 5, 2024
52770ed
Exceptions class added
Chiarena Feb 5, 2024
e65d1c3
Delete function added
Chiarena Feb 5, 2024
c9ede7f
Added save feature
Chiarena Feb 12, 2024
7c7eb0f
date time added
Chiarena Feb 18, 2024
a45e142
oop done
Chiarena Feb 23, 2024
cecd03d
Classes arranged into packages
Chiarena Feb 23, 2024
396cf5c
Merge remote-tracking branch 'origin/add-gradle-support'
Chiarena Feb 25, 2024
11e9506
isExit corrected
Chiarena Feb 25, 2024
f829900
corrected bye command to terminate program
Chiarena Feb 25, 2024
89331f7
JUnit tests added
Chiarena Feb 25, 2024
4459683
java docs added
Chiarena Feb 25, 2024
61137a6
removed redundant code
Chiarena Feb 25, 2024
eb8604d
Find feature added
Chiarena Feb 25, 2024
c1110ed
Coding standard improved
Chiarena Feb 25, 2024
e785e0e
Merge branch 'branch-A-JavaDoc'
Chiarena Feb 26, 2024
fca0a8a
Merge branch 'branch-A-CodingStandard'
Chiarena Feb 26, 2024
b21992a
Merge branch 'branch-Level-9'
Chiarena Feb 26, 2024
1f9dfe6
further corrected code after merging
Chiarena Feb 26, 2024
96ec174
Add critical assertions across to the parser class
Chiarena Feb 26, 2024
d8808e1
The code for each class is edited and sectioned to improve code quality
Chiarena Feb 26, 2024
a7c37b3
Merge pull request #3 from Chiarena/branch-A-Assertions
Chiarena Feb 26, 2024
ed78efc
Merge branch 'master' into branch-CodeQuality
Chiarena Feb 26, 2024
1fa1a03
Merge pull request #2 from Chiarena/branch-CodeQuality
Chiarena Feb 26, 2024
222176b
update feature added
Chiarena Feb 26, 2024
f075d9c
Update README.md
Chiarena Feb 26, 2024
14682ee
README edited
Chiarena Feb 26, 2024
0daaeec
Added user guide
Chiarena Feb 29, 2024
a8872c7
JavaFX
Chiarena Feb 29, 2024
774cdc7
Merge branch 'branch-Level-10'
Chiarena Feb 29, 2024
b3794f2
JavaFX edited
Chiarena Feb 29, 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
47 changes: 33 additions & 14 deletions src/main/java/Duke.java

Choose a reason for hiding this comment

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

Could probably store the lines as a constant value to make the code easier to change.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import java.util.ArrayList;
import java.util.Scanner;
public class Duke {
public static String printIntro() {
Expand All @@ -17,12 +18,12 @@ public static String printOutro() {
"____________________________________________________________\n";
}

public static String list(Task[] a, int counter) {
public static String list(ArrayList<Task> a, int counter) {
String x = ("Here are the tasks in your list: " + "\n" +
"____________________________________________________________\n");
String result = "";
for (int i = 0; i < counter; i++) {
result += (i + 1) + ". " + a[i].toString() + "\n";
result += (i + 1) + ". " + a.get(i).toString() + "\n";
}
String y = ("____________________________________________________________\n");
return x + result + y;
Expand Down Expand Up @@ -65,6 +66,18 @@ public static String getTime(String message) {
return time;
}

public static String deleteMessage(Task task, int count) {
return "____________________________________________________________\n" +
"Noted. I've removed this task:" + "\n" + task.toString() + "\n" +
"Now you have " + count + " tasks in the list." + "\n" +
"____________________________________________________________\n";
}

public static ArrayList<Task> delete(ArrayList<Task> a, int count) {

Choose a reason for hiding this comment

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

The method name could be changed to explain more about what this method is deleting.

a.remove(count);
return a;
}

public static String replace(String message) {
String newString = message.replaceAll("/(\\w+)", "$1:");
return newString;
Expand All @@ -76,7 +89,7 @@ public static void main(String[] args) {
System.out.println("Enter Message");

final int ArraySize = 100;

Choose a reason for hiding this comment

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

Constants should be in screaming_snake_case.

Task[] tasks = new Task[ArraySize];
ArrayList<Task> tasks = new ArrayList<>(ArraySize);
int counter = 0;

while (true) {
Expand All @@ -88,19 +101,22 @@ public static void main(String[] args) {
break;

} else if (message.equals("list")) {
System.out.println(list(tasks, counter));
System.out.println(list(tasks, tasks.size()));

} else if (message.startsWith("mark") || message.startsWith("unmark")) {
} else if (message.startsWith("mark") || message.startsWith("unmark") || message.startsWith("delete")) {
String[] parts = message.split(" ");
int num = Integer.parseInt(parts[1]);
Task current = tasks[num - 1];
Task current = tasks.get(num - 1);

if (message.startsWith("mark")) {
current.markAsDone();
System.out.println(printMark(current));
} else {
} else if (message.startsWith("unmark")){
current.unmark();
System.out.println(printMark(current));
}else{

Choose a reason for hiding this comment

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

I think you may have forgotten to add a space before and after the 'else' here.

tasks.remove(num - 1);
System.out.println(deleteMessage(current, tasks.size()));
}
} else if (message.equals("todo") || message.equals("deadline") || message.equals("event")){
throw new DukeExceptions("Don't forget the description !");
Expand All @@ -109,25 +125,28 @@ public static void main(String[] args) {
if (message.startsWith("todo")) {
String[] parts = message.split(" ", 2);
String task = parts[1];
tasks[counter] = new Todo(task);
// tasks[counter] = new Todo(task);

Choose a reason for hiding this comment

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

consider removing these comments once code is finalised :)

tasks.add(new Todo(task));
counter++;
System.out.println(added(tasks[counter - 1], counter));
System.out.println(added(tasks.get(counter - 1), counter));
} else if (message.startsWith("deadline")) {
String task = getTask(message);
String[] parts = time.split("by");
tasks[counter] = new Deadline(task, parts[1]);
// tasks[counter] = new Deadline(task, parts[1]);
tasks.add(new Deadline(task, parts[1]) );

Choose a reason for hiding this comment

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

Suggested change
tasks.add(new Deadline(task, parts[1]) );
tasks.add(new Deadline(task, parts[1]));

counter++;
System.out.println(added(tasks[counter - 1], counter));
System.out.println(added(tasks.get(counter - 1), counter));
} else {
String task = getTask(message);
String[] parts = time.split("from");
String[] dateParts = parts[1].split("/to");
tasks[counter] = new Event(task, dateParts[0], dateParts[1]);
// tasks[counter] = new Event(task, dateParts[0], dateParts[1]);
tasks.add(new Event(task, dateParts[0], dateParts[1]));
counter++;
System.out.println(added(tasks[counter - 1], counter));
System.out.println(added(tasks.get(counter - 1), counter));
}

}else {
} else {
throw new DukeExceptions("Sorry, I'm not sure what you mean");
}

Expand Down