-
Notifications
You must be signed in to change notification settings - Fork 434
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
[jasperng] iP #461
base: master
Are you sure you want to change the base?
[jasperng] iP #461
Conversation
Let's tweak the docs/README.md (which is used as the user guide) to fit Duke better. Specifically, 1. mention product name in the title 2. mention adding a product screenshot and a product intro 3. tweak the flow to describe feature-by-feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start. The basics are there just some modifications to the Luke class are needed.
src/main/java/Deadline.java
Outdated
@@ -0,0 +1,13 @@ | |||
public class Deadline extends Task { | |||
protected String by; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is using protected the most suitable option ? It makes it accessible to other classes from the same package ... I noticed the same issue in several other places too.
src/main/java/Event.java
Outdated
@@ -0,0 +1,16 @@ | |||
public class Event extends Task{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace should proceed { , according to our coding standard. Just something to take note.
src/main/java/Luke.java
Outdated
|
||
// Conditions | ||
while (!input.equals("bye")) { | ||
if (input.equals("list")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider creating functions to execute the commands ? E.g. when input.equals("list ") it call a separate function like outputTasks(). You can possibly perform you validation checks in these functions as well.
src/main/java/Luke.java
Outdated
import java.util.ArrayList; | ||
import java.util.Scanner; | ||
|
||
public class Luke { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe enhance the class structure by decomposing the functionality into separate classes such as InputValidator for validating user inputs, Outputs for managing output operations, and InputInterpreter for processing user commands, thereby promoting a clearer separation of concerns.
src/main/java/Luke.java
Outdated
|
||
// Conditions | ||
while (!input.equals("bye")) { | ||
if (input.equals("list")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider switching to a case statement it can potentially enhance code readability.
src/main/java/Luke.java
Outdated
int index = Integer.parseInt(instruction[1]) - 1; // array is 0-indexed | ||
|
||
if (index >= list.size()) { | ||
throw new LukeException("Hold up!! There is no such task in the list.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see you are already incorporating Exceptions.
src/main/java/TaskException.java
Outdated
@@ -0,0 +1,5 @@ | |||
public class TaskException extends Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe have this extend LukeException ? e.g. LukeTaskException. Won't have to check for LukeException | TaskException for each relevant exception.
src/main/java/Luke.java
Outdated
} | ||
System.out.println("________________________________________________________________________"); | ||
|
||
} else if (input.contains("mark")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a redundant if check. You can just split the string and verify if the mark/ unmark is present, while also ensuring the length of the split instruction is 2. This way, you confirm the task name's presence without extra checks. This might be applicable for other commands as well.
src/main/java/Luke.java
Outdated
// User inputs | ||
Scanner sc = new Scanner(System.in); | ||
String input = sc.nextLine(); | ||
ArrayList<Task> list = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly a more appropriate variable name to make the code more readable.
src/main/java/Luke.java
Outdated
|
||
} else { | ||
try { | ||
if (input.equals("todo") || input.equals("deadline") || input.equals("event")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider the case where user enters "todo " or "deadline " or "event ".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on coding standards. Seems like it was well followed.
src/main/java/Deadline.java
Outdated
@@ -0,0 +1,13 @@ | |||
public class Deadline extends Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaDoc comments of classes and functions would be nice.
src/main/java/Event.java
Outdated
@Override | ||
public String toString() { | ||
return "[E]" + super.toString() + " (from: " + this.from + " to: " + this.to + ")"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespaces are quite prevalent in your code. Just remove them and you're good.
import luke.exception.FileException; | ||
import luke.exception.LukeException; | ||
import luke.exception.TaskException; | ||
import luke.task.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if you split the wildcard import and instead import each module explicitly?
* @param ui The user interface. | ||
* @param storage The storage of the tasks. | ||
*/ | ||
public void parse(TaskList list, Ui ui, Storage storage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will a switch-case work better instead of if-else blocks?
} else if (input.contains("delete")) { | ||
try { | ||
if (input.equals("delete")) { | ||
throw new LukeException("Hold up!! There must be a task to delete!\n" | ||
+ "Please enter an index after " + input + "."); | ||
} | ||
|
||
try { | ||
String[] instruction = input.split(" "); | ||
String delete = instruction[0]; | ||
|
||
if (!delete.equals("delete")) { | ||
throw new LukeException("Hold up!! I am sorry, but I don't know what you mean by that :'("); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using ".startsWith("delete")" instead to check for commands? That way, you wouldn't need a separate if equals block.
// 6 is the index after "event ", so starts from index 6 | ||
// -1 to remove the space before "/from" | ||
String description = input.substring(6, input.indexOf("/from") - 1); | ||
// +6 to remove the "/from " and start from the index after "/from " | ||
// -1 to remove the space before "/to" | ||
String from = input.substring(input.indexOf("/from") + 6, input.indexOf("/to") - 1); | ||
// +4 to remove the "/to " and start from the index after "/to " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you use comments to explain the purpose of your code.
import luke.exception.DateException; | ||
import luke.parser.DateTimeParser; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you separated the imports by packages.
src/main/java/luke/ui/Ui.java
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to have a separate function of constant variable to print the horizontal lines instead?
Ensuring consistent coding standards is crucial for code quality and readability. Applied CheckStyle rules to the entire codebase. Resolved CheckStyle violations related to indentation, naming conventions, and coding style. Enforcing CheckStyle rules ensures a clean and consistent codebase, making it easier to maintain and understand.
The readTask() method is too long. To enhance code maintainability and readability, it is necessary to address the existing method's length and complexity. Using a new method handleMarkOrUnmark(), to handle the conditional statement to shorten the method length and make it more readable.
The current situation lacks assumption in the Storage and Luke classes. Introduce assertions at various points to ensure that important assumptions are made before running the rest of the code.
Add assertions into Storage and Luke classes
Add more methods to separate and shorten the parse method
Luke
SUPERFAST to useAnd it is FREE!
Features:
Note
There some things to note.
this is an inline
code
it has back-ticksaround
it