Skip to content

[Liu Hao] ip#115

Open
AaronZZ10 wants to merge 36 commits into
nus-cs2113-AY2425S1:masterfrom
AaronZZ10:master
Open

[Liu Hao] ip#115
AaronZZ10 wants to merge 36 commits into
nus-cs2113-AY2425S1:masterfrom
AaronZZ10:master

Conversation

@AaronZZ10

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/Taylor.java Outdated
String input = sc.nextLine();
List<Task> tasks = new ArrayList<>();
while(!input.equals("bye")) {
if(input.equals("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.

Is it possible to use a switch-case instead of if-else?

Comment thread src/main/java/Taylor.java Outdated
if(input.equals("list")) {
System.out.println(line);
System.out.println("Here are the tasks in your list:");
for(int i = 0; i < tasks.size(); i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since tasks.size() is repeated used in all of the loops, perhaps can create a variable to store this value

Comment thread src/main/java/Taylor.java Outdated
if(input.startsWith("mark")){
String[] words = input.split(" ");
int index = Integer.parseInt(words[1])-1;
if(index<0 || index>=tasks.size()) {

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 can place the code for checking in a method to allow easier reading

Comment thread src/main/java/Taylor.java Outdated

String input = sc.nextLine();
List<Task> tasks = new ArrayList<>();
while(!input.equals("bye")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For all the printing of the statements, maybe can put it in a method each. For instance, printTodoAdded() and the statement that the todo task have been added will be printed

Comment thread src/main/java/Taylor.java Outdated
int from = input.indexOf("/from");
int to = input.indexOf("/to");
String description = input.substring(6,from);
String _from = input.substring(from+6,to);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Preferably used another name instead of _from or _to as it is similar as from and to, which can be confusing

@PrinceCatt PrinceCatt 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.

  1. Your base class of tasks and other classes extending it look quite nice
  2. Coding standard looks good to me
  3. Your naming is not very consistent. Some are camelCasem while some are not: like _by
  4. Plural fine, boolean naming fine,

@kaboomzxc kaboomzxc 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 code quality

Comment thread src/main/java/Taylor.java Outdated
import java.util.*;

// Main class to implement a task manager called "Taylor"
public class Taylor {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

didn't do deep nesting, which is good code quality

Comment thread src/main/java/Taylor.java Outdated
// Initialize a scanner object to take user input
Scanner sc = new Scanner(System.in);

// Define a separator line for display purposes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

appropriate code comments explanations are helpful

Comment thread src/main/java/Taylor.java Outdated
if(input.startsWith("mark")){
String[] words = input.split(" ");
int index = Integer.parseInt(words[1])-1; // Parse task index
if(index<0 || index>=tasks.size()) { // Check if index is valid

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

error handling for Invalid Input is very useful

Comment thread src/main/java/Taylor.java Outdated
}

// Handle "todo" command to add a new Todo task
if(input.startsWith("todo")){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clear input handling for all the multiple types of commands (list, mark, unmark, todo, event, deadline)

@tzerbin tzerbin 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 attempt in following the guidelines!

Just a few things with regards to switch statements, magic numbers/strings and descriptive names for methods.

* @throws IOException If an I/O error occurs while reading the file.
* @throws TaylorException If the file contains an unknown task type.
*/
public ArrayList<Task> load() throws IOException, TaylorException {

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 provide a better descriptive name for the method?
This applies to the method names in this file such as "save" as well.

String description = parts[2].trim();

switch (taskType) {
case "T" -> tasks.add(new Todo(description, isCompleted));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please follow the structure of switch statements using breaks and colons, instead of arrow.

* The Taylor class handles user commands and manages task operations.
*/
public class Taylor {
private final Storage storage;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Constants should use SCREAMING_SNAKE_CASE instead.

* @return The next user command input.
* @throws TaylorException If an unknown command is encountered.
*/
private String operate(String input) throws TaylorException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This method is very long, perhaps abstract some details out into new functions (especially for the code in switch statements)?

ui.showTaskAdded(tasks.get(index), tasks);
storage.save(tasks);
} catch (IOException e) {
ui.println("Unable to write to 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.

There are a lot of instances of magic numbers and strings in the codebase, please use constants instead.

/**
* Displays the welcome message when the program starts.
*/
public void showWelcome() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be more appropriate to use the verb "print" instead of "show".
This applies to other methods in this file.


import java.util.Scanner;

/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Very nice usage of comments in all files.

*
* @return A string representing the task suitable for file storage.
*/
public abstract String write();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please use more descriptive method name!

Suggested change
public abstract String write();
public abstract String writeToFile();

* @param keyword The keyword to search for in the task descriptions.
* @return A string containing the matching tasks with their index, or null if no match is found.
*/
public String find(String keyword) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This method could use a more descriptive name as well.

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.

5 participants