Giter Site home page Giter Site logo

ip's Introduction

Duke project template

This is a project template for a greenfield Java project. 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/Duke.java file, right-click it, and choose Run Duke.main() (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
    Hello from
     ____        _        
    |  _ \ _   _| | _____ 
    | | | | | | | |/ / _ \
    | |_| | |_| |   <  __/
    |____/ \__,_|_|\_\___|
    

ip's People

Contributors

sweetpotato0213 avatar j-lum avatar damithc avatar jiachen247 avatar

ip's Issues

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

@SweetPotato0213 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

No easy-to-detect issues ๐Ÿ‘

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/duke/Deadline.java lines 31-31:

        // this.by = LocalDate.parse(by, DateTimeFormatter.ofPattern("yyyy-MM-dd"));

Example from src/main/java/duke/Duke.java lines 3-3:

//import javafx.application.Application;

Example from src/main/java/duke/Duke.java lines 4-4:

//import javafx.scene.Scene;

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/duke/Parser.java lines 26-146:

    public String parser(String input) {
        String[] inputArr = input.split(" ");
        String action = inputArr[0];

        int number;
        Task task;
        String[] params;
        try {
            switch (action) {
            case "list":
                return printList();
            case "mark":
                if (inputArr.length > 2 || inputArr.length == 1) {
                    throw new DukeException("The format should be: mark <number>");
                }
                number = Integer.parseInt(inputArr[1]);
                if (number > tasks.getSize()) {
                    throw new DukeException("The index is invalid!");
                }
                task = tasks.getTask(number - 1);
                task.markAsDone();
                return BREAK_LINE + "\n"
                        + "     Nice! I've marked this task as done:\n       "
                        + task + "\n" + BREAK_LINE;
            case "unmark":
                if (inputArr.length > 2 || inputArr.length == 1) {
                    throw new DukeException("The format should be: unmark <number>");
                }
                number = Integer.parseInt(inputArr[1]);
                if (number > tasks.getSize()) {
                    throw new DukeException("The index is invalid!");
                }
                task = tasks.getTask(number - 1);
                task.markAsNotDone();
                return BREAK_LINE + "\n"
                        + "     Nice! I've marked this task as not done yet:\n       "
                        + task + "\n" + BREAK_LINE;
            case "todo":
                if (input.substring(4).replaceAll("\\s+", "").equals("")) {
                    throw new DukeException("The description of a todo cannot be empty.");
                }
                task = new Todo(input.substring(5));
                tasks.addTask(task);
                return printTask(task);
            case "deadline":
                if (input.substring(8).replaceAll("\\s+", "").equals("")) {
                    throw new DukeException("The description of a deadline cannot be empty.");
                }
                if (!input.contains("/by")) {
                    throw new DukeException("The timing of a deadline cannot be omitted.");
                }
                params = input.substring(9).split(" /by ");
                task = new Deadline(params[0], params[1]);
                tasks.addTask(task);
                return printTask(task);
            case "event":
                if (input.substring(5).replaceAll("\\s+", "").equals("")) {
                    throw new DukeException("The description of an event cannot be empty.");
                }
                if (!input.contains("/at")) {
                    throw new DukeException("The timing of an event cannot be omitted.");
                }
                params = input.substring(6).split(" /at ");
                task = new Event(params[0], params[1]);
                tasks.addTask(task);
                return printTask(task);
            case "delete":
                if (inputArr.length > 2 || inputArr.length == 1) {
                    throw new DukeException("The format should be: delete <number>");
                }
                number = Integer.parseInt(inputArr[1]);
                if (number > tasks.getSize()) {
                    throw new DukeException("The index is invalid!");
                }
                task = tasks.getTask(number - 1);
                tasks.deleteTask(number - 1);
                return BREAK_LINE + "\n"
                        + "     Okay! I've removed this task from the list:\n       "
                        + task + "\n" + BREAK_LINE + "\n";
            case "find":
                String keyWord = input.substring(5);
                if (keyWord.replaceAll("\\s+", "").equals("")) {
                    throw new DukeException("The description of a find query cannot be empty.");
                }

                ArrayList<Task> matches = new ArrayList<Task>();
                for (int i = 0; i < tasks.getSize(); i++) {
                    task = tasks.getTask(i);
                    if (task.getDescription().contains(keyWord)) {
                        matches.add(task);
                    }
                }

                return printMatch(matches);
            case "update":
                if (input.substring(6).replaceAll("\\s+", "").equals("")) {
                    throw new DukeException("The description of an update cannot be empty.");
                }
                for (int i = 0; i < tasks.getSize(); i++) {
                    task = tasks.getTask(i);
                    if (task.getDescription().contains(inputArr[1])) {
                        tasks.deleteTask(i);
                        if (task instanceof Deadline) {
                            tasks.addTask(new Deadline(inputArr[1], inputArr[2]));
                        } else if (task instanceof Event) {
                            tasks.addTask(new Event(inputArr[1], inputArr[2]));
                        } else {
                            throw new DukeException("No more to update for this task");
                        }
                        return printTask(task);
                    }
                }
                throw new DukeException("Cannot find an existing task matching the update");
            default:
                throw new DukeException("I'm sorry, but I don't know what that means :-(");
            }
        } catch (DukeException err) {
            return BREAK_LINE + "\n" + "     โ˜น OOPS!!! "
                    + err + "\n" + BREAK_LINE + "\n";
        }
    }

Example from src/main/java/duke/Storage.java lines 31-74:

    public ArrayList<Task> loadData() throws DukeException {
        ArrayList<Task> tasks = new ArrayList<>();
        try {
            File taskFile = new File(this.path);
            Scanner sc = new Scanner(taskFile);
            while (sc.hasNext()) {
                String input = sc.nextLine();
                String[] inputArr = input.split(" \\| ");
                String type = inputArr[0];
                Task task;
                switch (type) {
                    case "T":
                        task = new Todo(inputArr[2]);
                        tasks.add(task);
                        if (inputArr[1].equals("1")) {
                            task.markAsDone();
                        }
                        break;
                    case "D":
                        task = new Deadline(inputArr[2], inputArr[3]);
                        tasks.add(task);
                        if (inputArr[1].equals("1")) {
                            task.markAsDone();
                        }
                        break;
                    case "E":
                        task = new Event(inputArr[2], inputArr[3]);
                        tasks.add(task);
                        if (inputArr[1].equals("1")) {
                            task.markAsDone();
                        }
                        break;
                    default:
                        throw new DukeException("It is an invalid type!");
                }
            }
            sc.close();
        } catch (FileNotFoundException err) {
            printError(err);
        } catch (DukeException err) {
            printError(err);
        }
        return tasks;
    }

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/duke/Ui.java lines 11-13:

    /**
     * Welcome Message: greet the user
     */

Example from src/main/java/duke/Ui.java lines 23-25:

    /**
     * Goodbye Message: bid farewell to the user
     */

Example from src/main/java/duke/Ui.java lines 34-36:

    /**
     * Error Message: remind the user
     */

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 (Subject Only)

possible problems in commit 57cac3f:

Added GUI

  • Not in imperative mood (?)

possible problems in commit 82f3c2b:

Added Main.java and fxml files

  • Not in imperative mood (?)

Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).

Aspect: Binary files in repo

Suggestion: Avoid committing binary files (e.g., *.class, *.jar, *.exe) or third-party library files in to the repo.

โ— 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.

Sharing iP code quality feedback [for @SweetPotato0213]

@SweetPotato0213 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

No easy-to-detect issues ๐Ÿ‘

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/duke/Deadline.java lines 29-29:

        // this.by = LocalDate.parse(by, DateTimeFormatter.ofPattern("yyyy-MM-dd"));

Example from src/main/java/duke/Event.java lines 29-29:

        // this.at = LocalDate.parse(at, DateTimeFormatter.ofPattern("yyyy-MM-dd"));

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/duke/Parser.java lines 26-151:

    public void parser() {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        String[] inputArr = input.split(" ");
        String action = inputArr[0];

        while (!action.equals("bye")) {
            int number;
            Task task;
            String[] params;
            try {
                switch (action) {
                case "list":
                    printList();
                    break;
                case "mark":
                    if (inputArr.length > 2 || inputArr.length == 1) {
                        throw new DukeException("The format should be: mark <number>");
                    }
                    number = Integer.parseInt(inputArr[1]);
                    if (number > tasks.getSize()) {
                        throw new DukeException("The index is invalid!");
                    }
                    task = tasks.getTask(number - 1);
                    task.markAsDone();
                    System.out.println(BREAK_LINE + "\n"
                            + "     Nice! I've marked this task as done:\n       "
                            + task + "\n" + BREAK_LINE);
                    break;
                case "unmark":
                    if (inputArr.length > 2 || inputArr.length == 1) {
                        throw new DukeException("The format should be: unmark <number>");
                    }
                    number = Integer.parseInt(inputArr[1]);
                    if (number > tasks.getSize()) {
                        throw new DukeException("The index is invalid!");
                    }
                    task = tasks.getTask(number - 1);
                    task.markAsNotDone();
                    System.out.println(BREAK_LINE + "\n"
                            + "     Nice! I've marked this task as not done yet:\n       "
                            + task + "\n" + BREAK_LINE);
                    break;
                case "todo":
                    if (input.substring(4).replaceAll("\\s+", "").equals("")) {
                        throw new DukeException("The description of a todo cannot be empty.");
                    }
                    task = new Todo(input.substring(5));
                    tasks.addTask(task);
                    printTask(task);
                    break;
                case "deadline":
                    if (input.substring(8).replaceAll("\\s+", "").equals("")) {
                        throw new DukeException("The description of a deadline cannot be empty.");
                    }
                    if (!input.contains("/by")) {
                        throw new DukeException("The timing of a deadline cannot be omitted.");
                    }
                    params = input.substring(9).split(" /by ");
                    task = new Deadline(params[0], params[1]);
                    tasks.addTask(task);
                    printTask(task);
                    break;
                case "event":
                    if (input.substring(5).replaceAll("\\s+", "").equals("")) {
                        throw new DukeException("The description of an event cannot be empty.");
                    }
                    if (!input.contains("/at")) {
                        throw new DukeException("The timing of an event cannot be omitted.");
                    }
                    params = input.substring(6).split(" /at ");
                    task = new Event(params[0], params[1]);
                    tasks.addTask(task);
                    printTask(task);
                    break;
                case "delete":
                    if (inputArr.length > 2 || inputArr.length == 1) {
                        throw new DukeException("The format should be: delete <number>");
                    }
                    number = Integer.parseInt(inputArr[1]);
                    if (number > tasks.getSize()) {
                        throw new DukeException("The index is invalid!");
                    }
                    task = tasks.getTask(number - 1);
                    tasks.deleteTask(number - 1);
                    System.out.println(BREAK_LINE + "\n"
                            + "     Okay! I've removed this task from the list:\n       "
                            + task + "\n" + BREAK_LINE + "\n");
                    break;
                case "find":
                    String keyWord = input.substring(5);
                    if (keyWord.replaceAll("\\s+", "").equals("")) {
                        throw new DukeException("The description of a find query cannot be empty.");
                    }

                    ArrayList<Task> matches = new ArrayList<Task>();
                    for (int i = 0; i < tasks.getSize(); i++) {
                        task = tasks.getTask(i);
                        if (task.getDescription().contains(keyWord)) {
                            matches.add(task);
                        }
                    }

                    if(matches.isEmpty()) {
                        throw new DukeException("There is no task matching this key word.");
                    } else {
                        System.out.println(BREAK_LINE + "\n"
                                + "     Okay! I've removed this task from the list:\n       ");
                        for (int i = 0; i < matches.size(); i++) {
                            System.out.println(i + 1 + ". " + matches.get(i));
                        }
                        System.out.println(BREAK_LINE + "\n");
                    }
                    break;
                default:
                    throw new DukeException("I'm sorry, but I don't know what that means :-(");
                }
            } catch (DukeException err) {
                System.out.println(BREAK_LINE + "\n" + "     โ˜น OOPS!!! "
                        + err + "\n" + BREAK_LINE + "\n");
            }
            input = sc.nextLine();
            inputArr = input.split(" ");
            action = inputArr[0];
        }
    }

Example from src/main/java/duke/Storage.java lines 31-74:

    public ArrayList<Task> load() throws DukeException {
        ArrayList<Task> tasks = new ArrayList<>();
        try {
            File taskFile = new File(this.path);
            Scanner sc = new Scanner(taskFile);
            while (sc.hasNext()) {
                String input = sc.nextLine();
                String[] inputArr = input.split(" \\| ");
                String type = inputArr[0];
                Task task;
                switch (type) {
                    case "T":
                        task = new Todo(inputArr[2]);
                        tasks.add(task);
                        if (inputArr[1].equals("1")) {
                            task.markAsDone();
                        }
                        break;
                    case "D":
                        task = new Deadline(inputArr[2], inputArr[3]);
                        tasks.add(task);
                        if (inputArr[1].equals("1")) {
                            task.markAsDone();
                        }
                        break;
                    case "E":
                        task = new Event(inputArr[2], inputArr[3]);
                        tasks.add(task);
                        if (inputArr[1].equals("1")) {
                            task.markAsDone();
                        }
                        break;
                    default:
                        throw new DukeException("It is an invalid type!");
                }
            }
            sc.close();
        } catch (FileNotFoundException err) {
            printError(err);
        } catch (DukeException err) {
            printError(err);
        }
        return tasks;
    }

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/duke/Parser.java lines 23-25:

    /**
     * Add corresponding tasks inputted by user to the list of tasks.
     */

Example from src/main/java/duke/Task.java lines 63-66:

    /**
     * A dummy function for subclasses to override
     * @return Empty string.
     */

Example from src/main/java/duke/TaskList.java lines 43-46:

    /**
     * Task Adder
     * @param task Task object to be added to the TaskList.
     */

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 (Subject Only)

No easy-to-detect issues ๐Ÿ‘

Aspect: Binary files in repo

Suggestion: Avoid committing binary files (e.g., *.class, *.jar, *.exe) or third-party library files in to the repo.

โ„น๏ธ 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.