Giter Club home page Giter Club logo

ip's Introduction

duke.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.duke.java file, right-click it, and choose Run duke.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

j-lum avatar damithc avatar chongjunwei avatar jiachen247 avatar

ip's Issues

Sharing iP code quality feedback [for @chongjunwei]

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 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.java lines 24-24:

        // System.out.println(file.mkdir());

Example from src/main/java/Duke.java lines 53-53:

                        // System.out.println(data);

Example from src/main/java/Duke.java lines 87-87:

                // arr.get(task).markAsDone();

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/Duke.java lines 8-273:

    public static void main(String[] args) {

        List<Task> arr = new ArrayList<>();
        int count = 0;
        String logo = " ____        _        \n"
                + "|  _ \\ _   _| | _____ \n"
                + "| | | | | | | |/ / _ \\\n"
                + "| |_| | |_| |   <  __/\n"
                + "|____/ \\__,_|_|\\_\\___|\n";
        String greeting = "____________________________________________________________\n" +
                "Hello! I'm Duke\n" +
                "What can I do for you?\n" +
                "____________________________________________________________\n";
        System.out.println(greeting);
        File folder = new File("data");
        folder.mkdir();
        // System.out.println(file.mkdir());
        File file = new File(folder, "duke.txt");
        try {
            file.createNewFile();
        } catch (IOException e) {
            System.out.println(e);
        }

        Scanner myObj = new Scanner(System.in);
        while (true) {
            String input = myObj.nextLine();
            if (input.equals("bye")) {
                String bye = "____________________________________________________________\n" +
                        "Bye. Hope to see you again soon!\n" +
                        "____________________________________________________________";
                System.out.println(bye);
                return;
            } else if (input.equals("list")) {
                System.out.println("____________________________________________________________");
                System.out.println("Here are the tasks in your list:");
/*
                for (int i = 0; i < count; i++) {
                    System.out.println("  " + (i + 1) + "." + arr.get(i).toString());
                }*/
                try {
                    Scanner reader = new Scanner(file);
                    int n = 0;
                    while (reader.hasNextLine()) {
                        String data = reader.nextLine();
                        // System.out.println(data);
                        String[] parsed = data.split(" \\| ");

                        String type = parsed[0];
                        String description = parsed[2];
                        n++;

                        if (type.equals("T")) {
                            Todo todo = new Todo(description);
                            if (parsed[1].equals("1")) {
                                todo.markAsDone();
                            }
                            System.out.println("  " + (n) + "." + todo.toString());
                        } else if (type.equals("D")) {
                            Deadline deadline = new Deadline(description, LocalDate.parse(parsed[3]));
                            if (parsed[1].equals("1")) {
                                deadline.markAsDone();
                            }
                            System.out.println("  " + (n) + "." + deadline.toString());
                        } else if (type.equals("E")) {
                            Event event = new Event(description, LocalDate.parse(parsed[3]));
                            if (parsed[1].equals("1")) {
                                event.markAsDone();
                            }
                            System.out.println("  " + (n) + "." + event.toString());
                        }
                    }
                } catch (FileNotFoundException e) {
                    System.out.println(e);
                }
                System.out.println("____________________________________________________________");
            } else if (input.startsWith("done ")) {
                int task = Integer.parseInt(input.split(" ")[1]);
                int n = 0;
                // arr.get(task).markAsDone();
                try {
                    Scanner reader = new Scanner(file);
                    List<String> lines = new ArrayList<>();
                    while (reader.hasNextLine()) {
                        n++;
                        String data = reader.nextLine();
                        if (task == n) {
                            String update = data.substring(0,4)+'1'+data.substring(5);
                            // System.out.println(update);
                            // System.out.println(data);
                            lines.add(update);
                        } else {
                            lines.add(data);
                        }
                        /*
                        System.out.println("____________________________________________________________");
                        System.out.println("Nice! I've marked this task as done:");
                        System.out.println("    " + arr.get(task).toString());
                        System.out.println("____________________________________________________________");
                         */
                        // mark as done
                    }

                    file.delete();
                    try {
                        file.createNewFile();
                        PrintWriter writer = new PrintWriter(file);
                        for (String line : lines) {
                            writer.println(line);
                        }
                        writer.close();
                    } catch (IOException e) {
                        System.out.println(e);
                    }
                } catch (FileNotFoundException e) {
                    System.out.println(e);
                }
            } else if (input.startsWith("todo")) {
                try {
                    if (input.split(" ").length == 1) {
                        throw new DukeException("____________________________________________________________\n" +
                                "โ˜น OOPS!!! The description of a todo cannot be empty.\n" +
                                "____________________________________________________________");
                    }
                    String task = input.split(" ")[1];
                    Todo todo = new Todo(task);
                    // arr.add(new Todo(task));
                    try {
                        Scanner reader = new Scanner(file);
                        List<String> lines = new ArrayList<>();
                        while (reader.hasNextLine()) {
                            String data = reader.nextLine();
                            lines.add(data);
                        }

                        file.delete();
                        try {
                            file.createNewFile();
                            PrintWriter writer = new PrintWriter(file);
                            for (String line : lines) {
                                writer.println(line);
                            }
                            writer.println(todo.addToFile());
                            writer.close();
                        } catch (IOException e) {
                            System.out.println(e);
                        }
                    } catch (FileNotFoundException e) {
                        System.out.println(e);
                    }
                    count++;
                    String s = "";
                    if (count > 1 && count != 0) {
                        s = "s";
                    }
                    String reply = "____________________________________________________________\n" +
                            "Got it. I've added this task:\n  " +
                            todo.toString() + "\n" +
                            "Now you have " + count + " task" + s + " in the list.\n" +
                            "____________________________________________________________";
                    System.out.println(reply);
                } catch (DukeException e) {
                    System.out.println(e);
                }
            } else if (input.startsWith("deadline")) {
                String[] n = input.split(" ", 2)[1].split(" /by ");
                // arr.add(new Deadline(n[0], n[1]));
                String task = n[0];
                LocalDate time = LocalDate.parse(n[1]);
                Deadline deadline = new Deadline(task, time);
                try {
                    Scanner reader = new Scanner(file);
                    List<String> lines = new ArrayList<>();
                    while (reader.hasNextLine()) {
                        String data = reader.nextLine();
                        lines.add(data);
                    }

                    file.delete();
                    try {
                        file.createNewFile();
                        PrintWriter writer = new PrintWriter(file);
                        for (String line : lines) {
                            writer.println(line);
                        }
                        writer.println(deadline.addToFile());
                        writer.close();
                    } catch (IOException e) {
                        System.out.println(e);
                    }
                } catch (FileNotFoundException e) {
                    System.out.println(e);
                }
                count++;
                String s = "";
                if (count > 1 && count != 0) {
                    s = "s";
                }
                String reply = "____________________________________________________________\n" +
                        "Got it. I've added this task:\n  " +
                        deadline.toString() + "\n" +
                        "Now you have " + count + " task" + s + " in the list.\n" +
                        "____________________________________________________________";
                System.out.println(reply);
            } else if (input.startsWith("event")) {
                String[] n = input.split(" ", 2)[1].split(" /at ");
                // arr.add(new Event(n[0], n[1]));
                String task = n[0];
                LocalDate time = LocalDate.parse(n[1]);
                Event event = new Event(task, time);
                try {
                    Scanner reader = new Scanner(file);
                    List<String> lines = new ArrayList<>();
                    while (reader.hasNextLine()) {
                        String data = reader.nextLine();
                        lines.add(data);
                    }

                    file.delete();
                    try {
                        file.createNewFile();
                        PrintWriter writer = new PrintWriter(file);
                        for (String line : lines) {
                            writer.println(line);
                        }
                        writer.println(event.addToFile());
                        writer.close();
                    } catch (IOException e) {
                        System.out.println(e);
                    }
                } catch (FileNotFoundException e) {
                    System.out.println(e);
                }
                count++;
                String s = "";
                if (count > 1 && count != 0) {
                    s = "s";
                }
                String reply = "____________________________________________________________\n" +
                        "Got it. I've added this task:\n  " +
                        event.toString() + "\n" +
                        "Now you have " + count + " task" + s + " in the list.\n" +
                        "____________________________________________________________";
                System.out.println(reply);
            } else if (input.startsWith("delete")) {
                int pos = Integer.parseInt(input.split(" ")[1]);
                Task task = arr.get(pos-1);
                arr.remove(pos-1);
                count--;
                String s = "";
                if (count > 1 && count != 0) {
                    s = "s";
                }
                String reply = "____________________________________________________________\n" +
                        "Noted. I've removed this task:\n  " +
                        task + "\n" +
                        "Now you have " + count + " task" + s + " in the list.\n" +
                        "____________________________________________________________";
                System.out.println(reply);
            } else {
                System.out.println(new DukeException("____________________________________________________________\n" +
                        "โ˜น OOPS!!! I'm sorry, but I don't know what that means :-(\n" +
                        "____________________________________________________________"));
            }
        }
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.

Aspect: Header Comments

No easy-to-detect issues ๐Ÿ‘

Aspect: Recent Git Commit Message (Subject Only)

possible problems in commit 4a0dbbb:

test

  • Perhaps too short (?)

possible problems in commit aa2c055:

Level-8

  • Perhaps too short (?)

possible problems in commit 5c22aee:

Level-8

  • Perhaps too short (?)

Suggestion: Follow the given conventions for Git commit messages

โ„น๏ธ The bot account @cs2103-bot 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 @chongjunwei] - Round 2

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

No easy-to-detect issues ๐Ÿ‘

Aspect: Method Length

No easy-to-detect issues ๐Ÿ‘

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

No easy-to-detect issues ๐Ÿ‘

Aspect: Recent Git Commit Message (Subject Only)

possible problems in commit 31592bb:

Added more tests for erroneous user input

  • Not in imperative mood (?)

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

โ— 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 @nus-se-bot 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.