Giter Site home page Giter Site logo

ip's Introduction

Duke project

This is a project for a Java chatbot that can help users manage their tasks. It's named after the Java mascot Duke. Given below are instructions on how to use it.

Setting up in Intellij

Prerequisites: JDK 11, update Intellij to the most recent version.

  1. Open Intellij (if you are not in the welcome screen, click File > Close Project to close the existing project first)
  2. Open the project into Intellij as follows:
    1. Click Open.
    2. Select the project directory, and click OK.
    3. If there are any further prompts, accept the defaults.
  3. Configure the project to use JDK 11 (not other versions) as explained in here.
    In the same dialog, set the Project language level field to the SDK default option.
  4. After that, locate the src/main/java/main/Main.java file, right-click it, and choose Run Main.main() (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see a window appears.

ip's People

Contributors

larrywang0701 avatar j-lum avatar damithc avatar seanleong339 avatar jiachen247 avatar eclipse-dominator avatar

ip's Issues

Sharing iP code quality feedback [for @larrywang0701]

@larrywang0701 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.

IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.

Aspect: Tab Usage

No easy-to-detect issues ๐Ÿ‘

Aspect: Naming boolean variables/methods

No easy-to-detect issues ๐Ÿ‘

Aspect: Brace Style

Example from src/main/java/command/CommandDeadlineHandler.java lines 19-20:

            }
            else{

Example from src/main/java/command/CommandDeleteHandler.java lines 17-18:

        }
        catch (NumberFormatException e){

Example from src/main/java/command/CommandEventHandler.java lines 20-21:

            }
            else{

Suggestion: As specified by the coding standard, use egyptian style braces.

Aspect: Package Name Style

No easy-to-detect issues ๐Ÿ‘

Aspect: Class Name Style

No easy-to-detect issues ๐Ÿ‘

Aspect: Dead Code

Example from src/main/java/main/Ui.java lines 122-122:

        //text.setTextAlignment(isUser ? TextAlignment.RIGHT : TextAlignment.LEFT);

Example from src/main/java/main/Ui.java lines 127-127:

        //VBox.setMargin(messageBubble, new Insets(0, 0, 0, isUser ? 350 : 0));

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/main/Ui.java lines 22-80:

    public void start(Stage primaryStage) throws Exception {
        INSTANCE = this;
        this.window = primaryStage;
        AnchorPane anchorPane = new AnchorPane();
        ScrollPane scrollPane = new ScrollPane();
        VBox dialogContainer = new VBox();
        this.dialogContainer = dialogContainer;
        scrollPane.setContent(dialogContainer);
        scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        TextField messageInputArea = new TextField();
        messageInputArea.setPrefSize(350, 20);
        messageInputArea.setLayoutX(0);
        messageInputArea.setLayoutY(600);
        Button sendMessageButton = new Button("Send");
        sendMessageButton.setPrefSize(50, 20);
        sendMessageButton.setLayoutX(350);
        sendMessageButton.setLayoutY(600);
        scrollPane.setPrefSize(400, 590);
        anchorPane.getChildren().addAll(scrollPane, messageInputArea, sendMessageButton);
        Scene mainScene = new Scene(anchorPane);
        primaryStage.setTitle("Chat with " + Main.getInstance().getName());
        primaryStage.setResizable(false);
        primaryStage.setMinHeight(600);
        primaryStage.setMinWidth(400);
        anchorPane.setPrefSize(400, 600);
        primaryStage.setScene(mainScene);
        primaryStage.show();
        primaryStage.setOnCloseRequest(event -> {
            ButtonType exitBtn = new ButtonType("Exit");
            ButtonType cancelBtn = new ButtonType("Cancel");
            Alert closeConfirmation = new Alert(Alert.AlertType.CONFIRMATION,"", cancelBtn, exitBtn);
            closeConfirmation.setHeaderText("Do you really want to exit?");
            closeConfirmation.showAndWait().ifPresent(
                    result->{
                        if(result == exitBtn){
                            this.byeAndExit();
                        }
                    }
            );
            event.consume();
        });

        sendMessageButton.setOnMouseClicked(event -> {
            String message = messageInputArea.getText();
            messageInputArea.setText("");
            this.addMessageBubble(message, true);
            Main.getInstance().getParser().executeCommand(message);
        });

        messageInputArea.setOnAction(event -> {
            String message = messageInputArea.getText();
            messageInputArea.setText("");
            this.addMessageBubble(message, true);
            Main.getInstance().getParser().executeCommand(message);
        });

        Main.getInstance().getParser().executeCommand("intro");
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/main/Main.java lines 48-52:

    /**
     * Main function for the program
     *
     * @param args The arugments from JVM
     */

Example from src/main/java/main/Main.java lines 76-80:

    /**
     * Return the name of the chat bot
     *
     * @return the name
     */

Example from src/main/java/main/Main.java lines 85-87:

    /**
     * Exit the program
     */

Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.

Aspect: Recent Git Commit Message

No easy-to-detect issues ๐Ÿ‘

Aspect: Binary files in repo

No easy-to-detect issues ๐Ÿ‘


โ„น๏ธ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected] if you want to follow up on this post.

Sharing iP code quality feedback [for @larrywang0701] - Round 2

@larrywang0701 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).

IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.

Aspect: Tab Usage

No easy-to-detect issues ๐Ÿ‘

Aspect: Naming boolean variables/methods

No easy-to-detect issues ๐Ÿ‘

Aspect: Brace Style

Example from src/main/java/command/CommandDeadlineHandler.java lines 26-27:

            }
            else{

Example from src/main/java/command/CommandDeleteHandler.java lines 24-25:

        }
        catch (NumberFormatException e) {

Example from src/main/java/command/CommandDurationHandler.java lines 26-27:

            }
            else{

Suggestion: As specified by the coding standard, use egyptian style braces.

Aspect: Package Name Style

No easy-to-detect issues ๐Ÿ‘

Aspect: Class Name Style

No easy-to-detect issues ๐Ÿ‘

Aspect: Dead Code

No easy-to-detect issues ๐Ÿ‘

Aspect: Method Length

Example from src/main/java/main/Ui.java lines 38-99:

    public void start(Stage primaryStage) throws Exception {
        INSTANCE = this;
        this.window = primaryStage;
        AnchorPane anchorPane = new AnchorPane();
        ScrollPane scrollPane = new ScrollPane();
        VBox dialogContainer = new VBox();
        this.dialogContainer = dialogContainer;
        scrollPane.setContent(dialogContainer);
        scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        TextField messageInputArea = new TextField();
        messageInputArea.setPrefSize(350, 20);
        messageInputArea.setLayoutX(0);
        messageInputArea.setLayoutY(600);
        Button sendMessageButton = new Button("Send");
        sendMessageButton.setPrefSize(50, 20);
        sendMessageButton.setLayoutX(350);
        sendMessageButton.setLayoutY(600);
        scrollPane.setPrefSize(400, 590);
        anchorPane.getChildren().addAll(scrollPane, messageInputArea, sendMessageButton);
        Scene mainScene = new Scene(anchorPane);
        primaryStage.setTitle("Chat with " + Main.getInstance().getName());
        primaryStage.setResizable(false);
        primaryStage.setMinHeight(600);
        primaryStage.setMinWidth(400);
        anchorPane.setPrefSize(400, 600);
        primaryStage.setScene(mainScene);
        primaryStage.show();
        primaryStage.setOnCloseRequest(event -> {
            ButtonType exitBtn = new ButtonType("Exit");
            ButtonType cancelBtn = new ButtonType("Cancel");
            Alert closeConfirmation = new Alert(Alert.AlertType.CONFIRMATION,"", cancelBtn, exitBtn);
            closeConfirmation.setHeaderText("Do you really want to exit?");
            closeConfirmation.showAndWait().ifPresent(
                    result->{
                        if(result == exitBtn) {
                            this.byeAndExit();
                        }
                    }
            );
            event.consume();
        });

        sendMessageButton.setOnMouseClicked(event -> {
            String message = messageInputArea.getText();
            messageInputArea.setText("");
            this.addMessageBubble(message, true, false);
            Main.getInstance().getParser().executeCommand(message);
        });

        messageInputArea.setOnAction(event -> {
            String message = messageInputArea.getText();
            messageInputArea.setText("");
            this.addMessageBubble(message, true, false);
            Main.getInstance().getParser().executeCommand(message);
        });

        this.portraitUser = new Image(this.getClass().getResourceAsStream("/images/Portrait_User.png"));
        this.portraitBot = new Image(this.getClass().getResourceAsStream("/images/Portrait_Bot.png"));
        Main.getInstance().loadTaskListFromFile();
        Main.getInstance().getParser().executeCommand("intro");
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/command/Parser.java lines 19-24:

    /**
     * Register a new command
     *
     * @param header the command's header
     * @param handler The command's handler
     */

Example from src/main/java/command/Parser.java lines 29-33:

    /**
     * Execute a command
     *
     * @param command the full command
     */

Example from src/main/java/main/Main.java lines 49-53:

    /**
     * Main function for the program
     *
     * @param args The arguments from JVM
     */

Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.

Aspect: Recent Git Commit Message

possible problems in commit 256371f:


Add error handling for exceptions when reading file

Add an error message box to tell the user there is an error and ask the user what to do when the program can not correctly load the task list from file.


  • body not wrapped at 72 characters: e.g., Add an error message box to tell the user there is an error and ask the user what to do when the program can not correctly load the task list from file.

Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).

Aspect: Binary files in repo

No easy-to-detect issues ๐Ÿ‘


โ— You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.

โ„น๏ธ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected] if you want to follow up on this post.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.