-
Notifications
You must be signed in to change notification settings - Fork 454
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
[Mengzhe] iP #466
base: master
Are you sure you want to change the base?
[Mengzhe] iP #466
Conversation
Task: added toString() method. Added Todo, Deadline and Event classes.
* branch-Level-8: Change the date time of Deadline and Event from string to LocalDateTime # Conflicts: # src/main/java/Duke.java Resolve the conflict
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.
Overall, I see consistent good coding standards being especially for the for
loops and conditional statements! The spacing and indentation made it super easy to read. However, I do observe some common places for improvements:
- ordering of the imports
- comments indentation and lack of javadoc comments
- naming of variables.
Nonetheless still good job! Looking forward to the more updated version as I think it may be a few versions behind the schedule.
src/main/java/Deadline.java
Outdated
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.temporal.ChronoUnit; | ||
|
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.
We need to add some JavaDoc comments for all public classes and methods. Noticed the lack of javadoc in some other places too.
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.
Yes indeed. I will add that in soon. Thank you for pointing it out.
src/main/java/Duke.java
Outdated
import java.util.Locale; | ||
import java.util.Scanner; | ||
import java.util.ArrayList; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.FileNotFoundException; | ||
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.
Should an empty line be added between imports from different packages? Also shall we order imports from same package by their alphabetical order?
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.
Yes, you are right. I will reorder them to make them look nicer.
src/main/java/Duke.java
Outdated
public class Duke { | ||
|
||
private static void appendToFile(String filePath, String textToAppend) throws IOException { | ||
FileWriter fw = new FileWriter(filePath, true); // create a FileWriter in append mode |
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.
Should comments be indented relative to their position in the code?
FileWriter fw = new FileWriter(filePath, true); // create a FileWriter in append mode | |
// create a FileWriter in append mode | |
FileWriter fw = new FileWriter(filePath, true); |
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.
you are right.
src/main/java/Duke.java
Outdated
// private static void printFileContents(File file) throws FileNotFoundException { | ||
// //File f = new File(filePath); // create a File for the given file path | ||
// Scanner s = new Scanner(file); // create a Scanner using the File as the source | ||
// while (s.hasNext()) { | ||
// System.out.println(s.nextLine()); | ||
// } | ||
// } | ||
|
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.
Shall we avoid such commented out codes?
src/main/java/Duke.java
Outdated
} else { | ||
// System.out.println("Data folder is already present."); | ||
} |
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 it possible that we take out the else clause then?
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.
yes thank you for pointing it out. i have removed it since.
src/main/java/Duke.java
Outdated
// mark a task as Done | ||
Pattern pattern = Pattern.compile("done\\s\\d+"); | ||
Matcher matcher = pattern.matcher(input); | ||
boolean matchFound = matcher.find(); |
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.
boolean matchFound = matcher.find(); | |
boolean ifMatchFound = matcher.find(); |
so that it sounds more like a boolean
src/main/java/Duke.java
Outdated
// delete a task | ||
Pattern patternDelete = Pattern.compile("delete\\s\\d+"); | ||
Matcher matcherDelete = patternDelete.matcher(input); | ||
boolean matchFoundDelete = matcherDelete.find(); |
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.
Same to the boolean name here as well.
src/main/java/Duke.java
Outdated
// Case Event | ||
if (group[0].equals(taskEve) && input.contains(" /at ")) { | ||
String[] eveGroup = input.split(" /at "); | ||
String eveToAdd = eveGroup[0].substring(6); // name of the task is after "event" and space |
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.
String eveToAdd = eveGroup[0].substring(6); // name of the task is after "event" and space | |
// name of the task is after "event" and space | |
String eveToAdd = eveGroup[0].substring(6); |
src/main/java/Event.java
Outdated
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.temporal.ChronoUnit; |
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.
The ordering of the imports can be better!
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.
yes i will improve upon it.
src/main/java/Task.java
Outdated
} | ||
|
||
public String getStatusIcon() { | ||
return (isDone ? "X" : " "); // mark done task with X |
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.
return (isDone ? "X" : " "); // mark done task with X | |
// mark done task with X | |
return (isDone ? "X" : " "); |
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.
Remember to complete the tasks from last week!
Mostly just need to extract away the Storage and Parser class so that the parsing and loading and storing of data can be abstracted away.
src/main/java/Duke.java
Outdated
// if data.txt does not exist, create file | ||
if (!dataFile.exists()) { | ||
try { | ||
File dataDirectory = new File("./data/data.txt"); | ||
if (dataDirectory.createNewFile()) { | ||
System.out.println("Data file has been created."); | ||
} else { | ||
// System.out.println("Data folder is already present."); | ||
} | ||
} catch (IOException e) { | ||
System.out.println("An error occurred."); | ||
e.printStackTrace(); | ||
} | ||
} |
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.
Could be extracted out to the Storage class to handle instead
src/main/java/Duke.java
Outdated
Pattern pattern = Pattern.compile("done\\s\\d+"); | ||
Matcher matcher = pattern.matcher(input); | ||
boolean matchFound = matcher.find(); | ||
if (matchFound) { |
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.
Perhaps let Parser class handle the match finding instead, and extract the code there.
…card to specific, create JAR file
…-Gradle * commit 'd8398594b7bc43da5eb865321c5a50cec4b3923d': Add Gradle support
Assertions are a crucial part of Java error handling since. It helps detects errors at runtime and terminates the application. Assertions are missing in this project. Add assert features in TaskList.java because it has many if blocks that are suitable for using assert.
Good code quality denotes that methods are not too long, not beyond one screen. Some methods in Storage.java and TaskList.java are too long. It is hard to read and locate specific functionalities. Extract the logic and create helper methods within its class.
Add assert feature
* master: Add assert feature
Improve code quality
We assume that users would not want to input the same task twice. This prevents possible confusion. TaskList allows the creation of duplicates. Add in methods to check for duplicating Todo, Deadline, and Event. Only add one if it is not a duplicate. This enhances user experience.
Find code to make Label of DialogBox have infinite height to accommodate longer responses on GitHub and CS2103 Forum. Acknowledge it.
It shows warning of incompatible version numbers when the application is executed. Remove the version number from fxml files.
Data file under the default path of ./data/data.txt may or may not exist. There is no need to create it if it already exists. The Storage class always creates the data file. If the file already exists, it will enter the catch block and print out error message when there is no error at all. Add in a check before creating the file. Only create it when it is not yet existent.
Should be the finalised version of README
DukeAzure
Here at DukeAzure, we help you be productive so you don't have to be busy taking down your tasks everywhere, ever.
Some selling points include:
fastVERY fastGet yours from here today!
Some simple steps to follow:
Some features (many more are on the way)
For those avid coders out there
Here is a snippet of the code. Feel free to give suggestions!
The
main
method of Duke: