Skip to content

[Hsien Kit] iP#102

Open
KHsienKit wants to merge 74 commits into
nus-cs2113-AY2425S1:masterfrom
KHsienKit:master
Open

[Hsien Kit] iP#102
KHsienKit wants to merge 74 commits into
nus-cs2113-AY2425S1:masterfrom
KHsienKit:master

Conversation

@KHsienKit

Copy link
Copy Markdown

No description provided.

@ZiliaAJY ZiliaAJY left a comment

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!

Comment on lines +2 to +3
private final String TYPE = "D";
private String by;

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 declaring attributes as protected rather than private as it would be easier to facilitate extension of subclasses as the project progress.

Comment thread src/main/java/V.java Outdated
Comment on lines +16 to +20
String logo = " _ _ \n"
+ "\\ \\ / / \n"
+ " \\ \\ / / \n"
+ " \\ \\_/ / \n"
+ " \\___/ \n";

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 to declare as public static final

Comment thread src/main/java/V.java Outdated
boolean isOnline = true;
Task[] listOfTasks = new Task[100];
int count = 0;
String temp;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

variable name "temp" can be more descriptive.

Comment thread src/main/java/V.java Outdated
Comment on lines +54 to +57
case "bye":
input.close();
isOnline = false;
break;

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 use of boolean flag isOnline as it allows the program to have a clear flow and makes the code easy to understand.

@shaunngoh shaunngoh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall, I found that your code was easy to read, though maintainability might be slightly harder due to the complex nature of your main function. Goodjob!

Comment thread src/main/java/V.java Outdated
Comment on lines +34 to +95
public static void main(String[] args) {
greet();

boolean isOnline = true;
Task[] listOfTasks = new Task[100];
int count = 0;
String temp;
String description;
String by;
String[] timePeriod;
String from;
String to;
String line;
String[] lineArr;
Scanner input = new Scanner(System.in);

while (isOnline) {
line = input.nextLine();
lineArr = line.trim().split(" ");
switch (lineArr[0]) {
case "bye":
input.close();
isOnline = false;
break;
case "list":
displayList(listOfTasks, count);
break;
case "mark":
int position = Integer.parseInt(lineArr[1]);
listOfTasks[position - 1].setDone();
displayList(listOfTasks, count);
break;
case "todo":
description = String.join(" ", Arrays.copyOfRange(lineArr, 1, lineArr.length));
listOfTasks[count] = new ToDo(description);
count++;
break;
case "event":
temp = String.join(" ", Arrays.copyOfRange(lineArr, 1, lineArr.length));
description = temp.split("/from")[0];
timePeriod = temp.split("/from")[1].split("/to");
from = timePeriod[0];
to = timePeriod[1];
listOfTasks[count] = new Event(description, from, to);
System.out.println(listOfTasks[count]);
count++;
break;
case "deadline":
temp = String.join(" ", Arrays.copyOfRange(lineArr, 1, lineArr.length));
description = temp.split("/by")[0];
by = temp.split("/by")[1];
listOfTasks[count] = new Deadline(description, by);
System.out.println(listOfTasks[count]);
count++;
break;
default:
System.out.println("Try again");
break;
}
}
printBlock("See Ya");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You could consider shortening your main method by breaking down the respective tasks into smaller methods

Comment thread src/main/java/Event.java
@@ -0,0 +1,25 @@
public class Event extends Task {
private final String TYPE = "E";

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 use of declaring a constant to determine the type of task when returning from the getType method!

Comment thread src/main/java/V.java Outdated
Comment on lines +37 to +48
boolean isOnline = true;
Task[] listOfTasks = new Task[100];
int count = 0;
String temp;
String description;
String by;
String[] timePeriod;
String from;
String to;
String line;
String[] lineArr;
Scanner input = new Scanner(System.in);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The respective variables here are hard to follow, maybe you could provide a comment for each of the variable's use case?

Comment thread src/main/java/V.java Outdated
String[] lineArr;
Scanner input = new Scanner(System.in);

while (isOnline) {

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 naming convention for your boolean variable!

KHsienKit and others added 29 commits September 24, 2024 21:48
Created a new class called TaskList to handle list functions
V will no longer display an empty list if the save file was empty
V was printing to terminal when loading the save file. This bug was fixed by adding a boolean isFromSaveFile parameter to the add tasks function where if the task was added from the save file, the function will not print the output of the addition of the task
Merge branch-A-JavaDoc to master

@okkhoy okkhoy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In general, code is well written. Try to organize the code as per A-Packages for better code management. Pay attention to (some of the) method names.

Comment thread src/main/java/Parser.java
Comment on lines +24 to +25
wordArray = command.trim().split(" ");
switch (wordArray[0].toLowerCase()) {

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 SLAP this out.

Comment thread src/main/java/Parser.java
taskList.deleteTask(position);
return true;
case "todo":
description = String.join(" ", Arrays.copyOfRange(wordArray, 1, wordArray.length));

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 SLAP this out; see the example from previous lecture.

* Loads save file using file path saved in <code>saveFilePath</code> attribute.
* Stores all the commands as a String in an array.
*/
public void loadSave() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the name can be better. reason: does loadSave mean load (read from file) or save (write to file)?

* A new file is created if it a save file does not exist.
* @param taskList list of tasks
*/
public void createSave(TaskList taskList) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same comment as above

for (Task task: list) {
switch(task.getType()) {
case "T":
saveFileWriter.write("todo " + task.getDescription() + System.lineSeparator());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you do have a toString() method, right? can try to us that here.

}

/**
* @return ArrayList of String containing all the commands from save file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

better: Returns the ArrayList of string ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants