[Caesar Pang] Duke Increments#350
[Caesar Pang] Duke Increments#350caesarpjz wants to merge 60 commits intonus-cs2103-AY1920S1:masterfrom
Conversation
Add toolVersion block in to Gradle code sample to prevent errors.
Change file mode on `gradle` to be executable (nus-cs2103-AY1920S1#9)
…Cleaned up my code more.
# Conflicts: # src/main/java/Duke.class # src/main/java/Duke.java # src/main/java/Task.class # src/main/java/Task.java Have completed all merge conflicts. This is the final draft for lvl 7 and lvl 8.
…only halfway done.
# Conflicts: # src/main/java/Event.class # src/main/java/Event.java # src/main/java/Storage.java # src/main/java/Task.class # src/main/java/TaskList.class # src/main/java/Todo.class # src/main/java/Todo.java
# Conflicts: # src/main/java/Ui.class
| /** | ||
| * Main method. | ||
| */ | ||
| public static void main(String[] args) throws IOException{ |
There was a problem hiding this comment.
I think this is a bad practice. You should probably catch the IOException somewhere within your code, rather than just throwing it from your main method.
| */ | ||
| @Override | ||
| public String toString() { | ||
| String date = formatDate(when); |
There was a problem hiding this comment.
You may want to consider storing this formatted date as a variable, so you don't have to keep converting it all the time.
| protected static ArrayList<Task> taskList = new ArrayList<Task>(); | ||
| protected static String file = "todo.txt"; | ||
|
|
||
| public Storage(String file) { |
There was a problem hiding this comment.
You should consider removing this parameter, since it doesn't seem to do anything.
| protected static ArrayList<Task> taskList = new ArrayList<Task>(); | ||
| protected static String file = "todo.txt"; | ||
|
|
||
| public Storage(String file) { |
There was a problem hiding this comment.
You should consider removing this parameter, since it doesn't seem to do anything.
| */ | ||
| public void addToFile(String filepath, String textToAdd) throws IOException { | ||
| FileWriter typer = new FileWriter(filepath, true); | ||
| typer.write(textToAdd + System.lineSeparator()); |
There was a problem hiding this comment.
Have to say that I didn't know about this System.lineSeparator() function. Looks like it might be useful for a cross-platform application. Good job 👍👍
| */ | ||
| public static int countLines(String filename) throws IOException { | ||
| try (InputStream inputs = new BufferedInputStream(new FileInputStream(filename))) { | ||
| byte[] characters = new byte[1024]; |
There was a problem hiding this comment.
Just curious, is there a reason you chose to use byte rather than char?
| * does not exist but cannot be created, or cannot be opened for any other reason. | ||
| */ | ||
| public void deleteCommand(String text) throws IOException { | ||
| int num = text.indexOf(" "); |
There was a problem hiding this comment.
Maybe this variable can be named better?
|
Overall, I think you did a great job with the documentation. I didn't notice any |
jon-chua
left a comment
There was a problem hiding this comment.
Your code is very well-documented 👍
As mentioned, I think it would be a good idea to abstract out parsing-related functionality to the Parser class.
On another note, your printed messages were interesting and useful 😄
Implementing more tests would prevent regressions from being introduced in the future too!
| int index = task.indexOf("["); | ||
| String taskType = task.substring(index + 1, index + 2); | ||
| int spaceIndex = task.indexOf(" "); | ||
| switch (taskType) { |
There was a problem hiding this comment.
There's a specific convention to follow for switch statements! https://nus-cs2103-ay1920s1.github.io/website/coding-standards/java/intermediate.html
| @@ -0,0 +1,167 @@ | |||
| import java.io.IOException; | |||
| import java.sql.SQLOutput; | |||
| * @throws IOException If the named file exists but is a directory rather than a regular file, | ||
| * does not exist but cannot be created, or cannot be opened for any other reason. | ||
| */ | ||
| public void eventCommand(String text) throws DukeException, IOException { |
There was a problem hiding this comment.
I think the parsing of the String should be moved to the Parser class, the TaskList class should be concerned with the operations on the list itself.
| * @throws IOException If the named file exists but is a directory rather than a regular file, | ||
| * does not exist but cannot be created, or cannot be opened for any other reason. | ||
| */ | ||
| public void deadlineCommand(String text) throws DukeException, IOException { |
There was a problem hiding this comment.
Similar to eventCommand, the parsing can be abstracted out to the Parser class.
| * command based on the input. Prints out error messages as well. | ||
| */ | ||
| public void nextCommand() { | ||
| while (scan.hasNext()) { |
There was a problem hiding this comment.
I think we should try to use the Parser class you have created to parse the input first! This way we can abstract out the parsing functions and so the UI class can just be concerned with the UI tasks.
groot0x12
left a comment
There was a problem hiding this comment.
Hi! You might want to clean up your repository by avoiding pushing your class files or just do a repository refactor. Overall, great effort but you might want to do more javadocs and documentation because it was a bit hard to understand the intention behind your code :)
| @@ -0,0 +1,15 @@ | |||
| public class Command { | |||
There was a problem hiding this comment.
I feel that this is a plausible solution but you might want to consider abstract classes as a more efficient way of inheritance for all your other command sub-classes.
|
|
||
| public String nextCommand(String input) { | ||
| String text = input; | ||
| switch () |
There was a problem hiding this comment.
Missing documentation and code looks incomplete. Missing a return statement as well. I'm guessing what you're trying to do here is abstract the Command class to have some form of inheritance, instead of using methods to facilitate your commands. You're on the right track, just add more to this switch statement.
| } | ||
|
|
||
|
|
||
| public static String dateFormatter(String text) { |
There was a problem hiding this comment.
This is definitely a plausible solution to obtaining substrings from the command. However, you might want to consider using the java String.split() method to make obtaining your data more efficient!
| import javafx.scene.image.Image; | ||
| import javafx.scene.image.ImageView; | ||
|
|
||
| public class Duke extends Application { |
There was a problem hiding this comment.
You might want to consider using multiple classes to facilitate your JavaFX GUI (MainWindow.java / DialogBox.java etc.)
Having all the code in your Duke.java makes it very messy and unreadable.
| ui.printIndent(); | ||
| switch (text) { | ||
| case "todo": | ||
| throw new DukeException("☹ OOPS!!! The description of a todo cannot be empty. " |
There was a problem hiding this comment.
Your error format can be stored in a string variable so that it's easy to reuse.
| String formatted = date; | ||
| if (!date.contains(")")) { | ||
| try { | ||
| Date d = new SimpleDateFormat("dd/MM/yyyy hhmm").parse(date); |
There was a problem hiding this comment.
Great effort in handling date and time!
Added assertions.
Better Code Quality.
Duke Increments