Skip to content
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

[Tan Wei, Adam] Duke Increments #361

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

MistyRainforest
Copy link

No description provided.

Copy link

@1nefootstep 1nefootstep left a comment

Choose a reason for hiding this comment

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

Hello! I think you can break up Duke.java into several different classes to help make future modifications smoother.

break;
case "todo":
case "event":
case "deadline":
Copy link

Choose a reason for hiding this comment

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

ohhhh, this seems interesting, how does switch case work in this scenario? ^-^

import static org.junit.jupiter.api.Assertions.*;

class DukeTest {

Copy link

Choose a reason for hiding this comment

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

Did you forget to include the body?

public ListItem(String description, String command) {
try {
switch (command) {
case "todo":
Copy link

Choose a reason for hiding this comment

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

Clear logic flow, but perhaps you can consider separating the different task types using different classes?

}
//try to catch more exceptions
catch (Exception e) {
dukePrint("☹ OOPS!!! The description of a " + userCommand + " cannot be empty.");

Choose a reason for hiding this comment

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

You might want to create a seperate DukeException class for this later on!

boolean exists = false;
String precursor = "";
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy HHss");
java.util.Date data;

Choose a reason for hiding this comment

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

Putting the date import at the start of the file as per convention would be better practice!

String precursor = "";
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy HHss");
java.util.Date data;
public Date(String dateString) {

Choose a reason for hiding this comment

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

Could write javadocs for the methods!

public String toString() {
if (exists) {
return "(" + precursor + " " + formatter.format(data) + ")";
}

Choose a reason for hiding this comment

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

Try to conform to the 2103 coding style!
the else { should be on the same line as '}'

* Date representation of date string that's given
*/
public class Date {
boolean exists = false;

Choose a reason for hiding this comment

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

Naming of boolean could be more semantic

* Prints what Duke says in correct format.
* @param texts any number of String arguments
* each prints on a new line.
*/

Choose a reason for hiding this comment

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

Unused javadoc could be removed.

/**
* Main driver class for Duke.
*
*/
public static void main(String[] args) {

Choose a reason for hiding this comment

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

Remove unused main method

ListItem(String description, String command, String date) {
try {
switch (command) {
case "todo":

Choose a reason for hiding this comment

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

Try to conform to the coding style! ( "case ..." should be on the same indent level as the switch statement )

@@ -0,0 +1,42 @@
import java.text.SimpleDateFormat;
Copy link

@ArunBeCoding ArunBeCoding Sep 12, 2019

Choose a reason for hiding this comment

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

Good choice to create a Date class, because it is easier to edit when you change the Date format.

java.util.Date data;
public Date(String dateString) {
precursor = dateString.split(" ", 2)[0];
if (!dateString.equals(" ")) {

Choose a reason for hiding this comment

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

Instead of this, use SLAP to abstract out the checking method.

private Button sendButton;
private Scene scene;

private Image user = new Image(this.getClass().getResourceAsStream("/images/User.jpg"));

Choose a reason for hiding this comment

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

You can consider storing the image path as a private static string to make it neater.

private static void echo(String echoedString) {
dukePrint(echoedString);
}

Choose a reason for hiding this comment

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

This should be in UI.

while(reader.hasNext()) {
String commandIn = reader.nextLine();
String[] commandArray = commandIn.split("@");
tempArray.add(new ListItem(commandArray[2], commandArray[1], commandArray[3]));

Choose a reason for hiding this comment

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

After you split the command, you can consider declaring each array item as a String for better understanding later, rather than commandArray[x]

*/
void save(ArrayList<ListItem> toSave) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(filepath));

Choose a reason for hiding this comment

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

Rmb to close BufferedWriter!

Copy link

@ArunBeCoding ArunBeCoding left a comment

Choose a reason for hiding this comment

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

Overall very creative code! We had a pleasant time reading your code! cheeers yeeeeeeeeeeeeeeeeet

else {
date = " ";
}
switch(userCommand) {

Choose a reason for hiding this comment

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

Your switch case formatting does not comply with the java coding standard. Try to change it like this (the case is not indented):

switch(something) {
case "x": 
    return x;
case "y":
    return y;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants