-
Notifications
You must be signed in to change notification settings - Fork 364
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
[jweeyh] iP #162
base: master
Are you sure you want to change the base?
[jweeyh] iP #162
Conversation
# Conflicts: # src/main/java/Duke.java # src/main/java/DukeList.java
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 code quality is pretty good! Good OOP with some mixor fixes to be done! Keep up the good work 😄
src/main/java/duke/Duke.java
Outdated
private Storage storage; | ||
private DukeList dukeList; | ||
private Ui ui; |
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 these 3 variables can be final?
src/main/java/duke/DukeList.java
Outdated
} | ||
System.out.println("Sure, Imma add that real quick"); | ||
System.out.println(task); | ||
list.add(task); | ||
System.out.println("Now you've got " + list.size() + pluralTask(list.size())); | ||
System.out.println(new TextBorder("")); | ||
} |
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 you can move all the prints into the Ui class? After all you have a Ui class and the Ui class should deal with interactions with the user
public class MarkCommand extends Command{ | ||
|
||
private String task; | ||
private boolean marker; |
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 change it to a more boolean sounding name like "isMarked" ?
src/main/java/duke/Parser.java
Outdated
if (inputText.equals("bye")) { | ||
return new ExitCommand(this.dukelist, this.storage); | ||
} else if (first.equals("list")){ | ||
return new ListCommand(this.dukelist); | ||
} else if (first.equals("mark")) { | ||
return new MarkCommand(array[1], true, dukelist); | ||
} else if (first.equals("unmark")) { | ||
return new MarkCommand(array[1], false, dukelist); | ||
} else if (first.equals("delete")){ | ||
return new DeleteCommand(array[1], dukelist); | ||
} else if (first.equals("find")) { | ||
return new FindCommand(array[1], dukelist); | ||
} else { | ||
if (array.length != 2) { | ||
if (first.equals("todo") || first.equals("deadline") || first.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 u can consider using switch for this part so it looks cleaner and improve readability?
src/main/java/duke/DukeList.java
Outdated
public void add(String type, String s) { | ||
Task task = new Task(); | ||
if (type.equals("todo")) { | ||
task = new Todo(s); | ||
|
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 this method could be named to be more descriptive like "addTask"
Hey Darius, thanks so much for the review!
…On Tue, Jan 31, 2023 at 1:00 AM Darius Ng ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/main/java/duke/DukeList.java
<#162 (comment)>
:
> + public void add(String type, String s) {
+ Task task = new Task();
+ if (type.equals("todo")) {
+ task = new Todo(s);
+
Maybe this method could be named to be more descriptive like "addTask"
—
Reply to this email directly, view it on GitHub
<#162 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AU4UEONHH52UFRYH6G4NC6TWU7XRXANCNFSM6AAAAAAUEUCHMY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
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.
Code looks good, some minor suggestions made feel free to disregard if found unnecessary. Cheers!
public class MarkCommand extends Command{ | ||
|
||
private String task; | ||
private boolean marker; |
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 isMarked could be used for your boolean variable?
src/main/java/duke/DukeList.java
Outdated
import task.*; | ||
import 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.
Would it be better to import all the classes instead?
src/main/java/duke/DukeList.java
Outdated
private String pluralTask (int size) { | ||
if (size == 1) { | ||
return " task."; | ||
} else { | ||
return " tasks."; | ||
} | ||
} |
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 put this in your Ui class?
src/main/java/duke/Parser.java
Outdated
@@ -0,0 +1,66 @@ | |||
package duke; | |||
|
|||
import command.*; |
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 to conform to conventions you would like to import each class separately?
src/main/java/duke/TextBorder.java
Outdated
|
||
public class TextBorder { | ||
String text; | ||
String border = "// / / // / / // / / // / / // / / // / / // /"; |
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 this can be static final?
# Conflicts: # src/main/java/command/ExitCommand.java # src/main/java/command/FindCommand.java # src/main/java/command/ListCommand.java # src/main/java/command/MarkCommand.java # src/main/java/duke/DukeList.java
Add Assert to SaveList in 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.
A brief review of code quality, mainly on these problems
a. weak SLAP
b. arrow-head style code
c. too-long methods
d. too-deep nesting
src/main/java/duke/Storage.java
Outdated
public DukeList retrieveList (Ui ui) { | ||
try { | ||
if ((new File(path)).exists()) { | ||
FileInputStream fis = new FileInputStream(path); | ||
ObjectInputStream ois = new ObjectInputStream(fis); | ||
try { | ||
DukeList savedDukeList = (DukeList) ois.readObject(); | ||
savedDukeList.setUi(ui); | ||
return savedDukeList; | ||
|
||
} catch (IOException e) { | ||
ui.addStatement("Creating new save"); | ||
} | ||
} | ||
|
||
} catch (FileNotFoundException e) { | ||
ui.addStatement("Hey sorry man, something's off bout you're save data."); | ||
ui.addStatement(e.toString()); | ||
} catch (IOException e) { | ||
ui.addStatement("Yo something's up with your I/O, gotta get it checked before doing this."); | ||
ui.addStatement(e.toString()); | ||
System.out.println(e); | ||
} catch (ClassNotFoundException e) { | ||
ui.addStatement("Hey I can't find your object class."); | ||
ui.addStatement(e.toString()); | ||
} | ||
return new DukeList(ui); | ||
} |
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 can make this double nested try-catch block into a single level try-catch
src/main/java/gui/Gui.java
Outdated
public void start(Stage primaryStage) throws Exception { | ||
scrollPane = new ScrollPane(); | ||
dialogContainer = new VBox(); | ||
scrollPane.setContent(dialogContainer); | ||
|
||
userInput = new TextField(); | ||
sendButton = new Button("Send"); | ||
|
||
AnchorPane mainLayout = new AnchorPane(); | ||
mainLayout.getChildren().addAll(scrollPane, userInput,sendButton); | ||
|
||
scene = new Scene(mainLayout); | ||
primaryStage.setScene(scene); | ||
primaryStage.show(); | ||
|
||
//2 | ||
primaryStage.setTitle("Duke"); | ||
primaryStage.setResizable(false); | ||
primaryStage.setMinHeight(600.0); | ||
primaryStage.setMinWidth(400.0); | ||
|
||
mainLayout.setPrefSize(400.0, 600.0); | ||
|
||
scrollPane.setPrefSize(385, 535); | ||
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); | ||
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); | ||
|
||
scrollPane.setVvalue(1.0); | ||
scrollPane.setFitToWidth(true); | ||
|
||
dialogContainer.setPrefHeight(Region.USE_COMPUTED_SIZE); | ||
|
||
userInput.setPrefWidth(325.0); | ||
|
||
sendButton.setPrefWidth(55.0); | ||
|
||
AnchorPane.setTopAnchor(scrollPane, 1.0); | ||
|
||
AnchorPane.setBottomAnchor(sendButton, 1.0); | ||
AnchorPane.setRightAnchor(sendButton, 1.0); | ||
|
||
AnchorPane.setLeftAnchor(userInput , 1.0); | ||
AnchorPane.setBottomAnchor(userInput, 1.0); | ||
|
||
sendButton.setOnMouseClicked((event) -> { | ||
handleUserInput(); | ||
}); | ||
|
||
userInput.setOnAction((event) -> { | ||
handleUserInput(); | ||
}); | ||
|
||
dialogContainer.getChildren().addAll( | ||
new DialogBox(new Label("Waddup the name's Duncan. Sorry but Duke couldn't make it, had a pretty bad stomach-ache."), new ImageView(duncan)), | ||
new DialogBox(new Label("So what do you need bro?"), new ImageView(duncan)) | ||
); | ||
} |
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.
While the use of SLAP is quite good here, the method seems a bit too long
src/main/java/duke/Parser.java
Outdated
} else { | ||
if (array.length != 2) { | ||
if (first.equals("todo") || first.equals("deadline") || first.equals("event")) { | ||
throw new EmptyDescriptionException("Sorry, your " + first + " task description is missing."); | ||
|
||
} else { | ||
throw new UnknownInputException("Hmm, I'm not sure what you're saying man."); | ||
|
||
} | ||
} | ||
return new AddCommand(array[0], array[1], dukelist); | ||
|
||
} | ||
} catch (ArrayIndexOutOfBoundsException e) { |
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.
This part of the code seems a bit too deeply nested
There was text present that contained the default String drawing of Duke, which was relevant only in CLI, but has since become redundant with the new GUI. This currently unused text is thus deleted in accordance with the coding standard to remove unused and outdated code. Let's try to find other instances in the code which could be simplified and refactored.
At the start of the run function, it is important that the statements in the Ui are cleared so that previous commands would not be executed unintentionally. An assert is thus placed after ui.clearStatements This is done to confirm that the Ui statements have been cleared
Add assert to the run function in Duke
# Conflicts: # src/main/java/duke/Parser.java
Branch Coding Standards
As a matter of housekeeping and storage, there might be tasks that need to be removed from the current list, but may be retrieved in the future An archive function that creates and stores another DukeList is implemented As an extension, the archive function can help to store redundant tasks in the main list into a separate list for future retrieval
No description provided.