Giter Club home page Giter Club logo

ip's Introduction

Cygnus Project

This is a project expanded from a greenfield Java project named 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 the application as shown below:

image

ip's People

Contributors

lowjiahao99 avatar j-lum avatar damithc avatar jiachen247 avatar

ip's Issues

Sharing iP code quality feedback [for @LowJiaHao99]

@LowJiaHao99 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/Duke.java lines 11-11:

        //Task[] tasks = new Task[100];

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

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

    public static void main(String[] args) {
        System.out.println(Commands.HI.toString());
        ArrayList<Task> tasks = new ArrayList<Task>();
        //Task[] tasks = new Task[100];
        Scanner sc = new Scanner(System.in);
        boolean isExit = false;
        while (!isExit) {
            String comm = sc.nextLine();
            String[] processedCommand = comm.split(" ", 2);
            Integer taskIndex = null;
            switch (processedCommand[0]) {
            case "hi":
                System.out.println(Commands.HI.toString());
                break;
            case "bye":
                System.out.println(Commands.BYE.toString());
                isExit = true;
                break;
            case "list":
                System.out.println(Commands.LIST.toString());
                for (int i = 0; i < tasks.size(); i++) {
                    int indexToPrint = i + 1;
                    System.out.println(String.format(
                        "    %d.%s", indexToPrint, tasks.get(i).identify()));
                }
                break;
            case "mark":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }
                try {
                    taskIndex = Integer.parseInt(processedCommand[1]) - 1;
                } catch (NumberFormatException e) {
                    new DukeException();
                    break;
                }

                //Mark task
                tasks.get(taskIndex).setIsDone(true);
                System.out.println(String.format(
                    "%s    %s", Commands.MARK.toString(), tasks.get(taskIndex).identify()));
                break;
            case "unmark":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }
                try {
                    taskIndex = Integer.parseInt(processedCommand[1]) - 1;
                } catch (NumberFormatException e) {
                    new DukeException();
                    break;
                }

                //Unmark task
                tasks.get(taskIndex).setIsDone(false);
                System.out.println(String.format(
                    "%s      %s", Commands.UNMARK.toString(), tasks.get(taskIndex).identify()));
                break;
            case "deadline":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                } else if (!processedCommand[1].contains("/by")) {
                    new DukeException();
                    break;
                }

                //Processing input
                String[] inputForDeadlineConstructor = processedCommand[1].split("/by", 2);
                inputForDeadlineConstructor[0] = inputForDeadlineConstructor[0].trim();
                LocalDate deadlineDate = null;
                try {
                    deadlineDate = LocalDate.parse(inputForDeadlineConstructor[1].trim());
                } catch (DateTimeParseException e) {
                    new DukeException();
                    break;
                }

                //Create deadline
                Deadline deadline = new Deadline(inputForDeadlineConstructor[0], deadlineDate);
                System.out.println(String.format(
                    "%s      %s", Commands.ADD.toString(), deadline.identify()));
                tasks.add(deadline);
                System.out.println(String.format("    Now you have %d tasks in the list.", tasks.size()));
                break;
            case "todo":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }

                //Create Todo
                ToDo todo = new ToDo(processedCommand[1]);
                System.out.println(String.format(
                    "%s      %s", Commands.ADD.toString(), todo.identify()));
                tasks.add(todo);
                System.out.println(String.format("    Now you have %d tasks in the list.", tasks.size()));
                break;
            case "event":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                } else if (!processedCommand[1].contains("/by")) {
                    new DukeException();
                    break;
                }

                //Input processing
                String[] inputForEventConstructor = processedCommand[1].split("/by", 2);
                inputForEventConstructor[0] = inputForEventConstructor[0].trim();
                LocalDate eventDate = null;
                try {
                    eventDate = LocalDate.parse(inputForEventConstructor[1].trim());
                } catch (DateTimeParseException e) {
                    new DukeException();
                    break;
                }

                //Create event
                Event event = new Event(inputForEventConstructor[0], eventDate);
                System.out.println(String.format(
                    "%s      %s", Commands.ADD.toString(), event.identify()));
                tasks.add(event);
                System.out.println(String.format("    Now you have %d tasks in the list.", tasks.size()));
                break;
            case "delete":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }
                try {
                    taskIndex = Integer.parseInt(processedCommand[1]) - 1;
                } catch (NumberFormatException e) {
                    new DukeException();
                    break;
                }

                Task deletedTask = tasks.remove((int)taskIndex);
                System.out.println(String.format(
                    "%s      %s\n    Now you have %d tasks in the list",
                    Commands.DELETE.toString(), deletedTask.identify(), tasks.size()));
                break;
            default:
                new DukeException();
            }
        }
        sc.close();
    }

Example from src/test/java/ParserTest.java lines 22-71:

    public void parse_InvalidInput_DukeExceptionThrown() {
        try {
            assertEquals(" ",  Parser.parse(" ", -1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("deadline",  Parser.parse("deadline tmr ", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("delete",  Parser.parse("delete t", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("deleted",  Parser.parse("deleted 1", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("listed",  Parser.parse("listed", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("event",  Parser.parse("event homework /by Tmr", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("event",  Parser.parse("event homework /by 202-11-10", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }
    }

Example from src/test/java/StorageTest.java lines 52-95:

    public void updateStorage_newTaskArrayList_containTasks() {
        String filePath = "dataTest.txt";
        File file = new File(filePath);
        if (Files.exists(Paths.get(filePath))) {
            try {
                Files.delete(file.toPath());
            } catch (IOException errorMessage) {
                fail();
            }
        }

        ArrayList<Task> tasks = new ArrayList<Task>();
        tasks.add(new ToDo("sleep"));
        tasks.add(new Event("run", LocalDate.parse("2021-10-10"), null));
        tasks.add(new Event("do homework", LocalDate.parse("2021-12-05"), null));

        Storage storage = new Storage(filePath);

        try {
            storage.updateStorageFile(tasks);
        } catch (DukeException errorMessage) {
            fail();
        }

        Scanner sc = null;
        try {
            sc = new Scanner(file);
        } catch (FileNotFoundException errorMessage) {
            fail();
        }

        for (int i = 0; i < 3; i++) {
            String expectedOutput =  String.format("    %s", tasks.get(i).toString());
            assertEquals(sc.nextLine().concat("\n"), expectedOutput);
        }

        sc.close();

        try {
            Files.delete(Paths.get(filePath));
        } catch (IOException errorMessage) {
            fail();
        }
    }

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: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/dukeclasses/Duke.java lines 138-143:

    /**
     * Execute methods related to the find command.
     *
     * @param command command that contains information for find command to execute.
     * @return String output that is printed in the GUI as Duke's response.
     */

Example from src/main/java/dukeclasses/Duke.java lines 152-157:

    /**
     * Execute methods related to the commands that change status of the task.
     *
     * @param command command that contains information for change of status command to execute.
     * @return String output that is printed in the GUI as Duke's response.
     */

Example from src/main/java/dukeclasses/Duke.java lines 177-182:

    /**
     * Execute methods related to the commands that deletes task.
     *
     * @param command command that contains information for delete command to execute.
     * @return String output that is printed in the GUI as Duke's response.
     */

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 ๐Ÿ‘

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

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

@LowJiaHao99 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/Duke.java lines 11-11:

        //Task[] tasks = new Task[100];

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

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

    public static void main(String[] args) {
        System.out.println(Commands.HI.toString());
        ArrayList<Task> tasks = new ArrayList<Task>();
        //Task[] tasks = new Task[100];
        Scanner sc = new Scanner(System.in);
        boolean isExit = false;
        while (!isExit) {
            String comm = sc.nextLine();
            String[] processedCommand = comm.split(" ", 2);
            Integer taskIndex = null;
            switch (processedCommand[0]) {
            case "hi":
                System.out.println(Commands.HI.toString());
                break;
            case "bye":
                System.out.println(Commands.BYE.toString());
                isExit = true;
                break;
            case "list":
                System.out.println(Commands.LIST.toString());
                for (int i = 0; i < tasks.size(); i++) {
                    int indexToPrint = i + 1;
                    System.out.println(String.format(
                        "    %d.%s", indexToPrint, tasks.get(i).identify()));
                }
                break;
            case "mark":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }
                try {
                    taskIndex = Integer.parseInt(processedCommand[1]) - 1;
                } catch (NumberFormatException e) {
                    new DukeException();
                    break;
                }

                //Mark task
                tasks.get(taskIndex).setIsDone(true);
                System.out.println(String.format(
                    "%s    %s", Commands.MARK.toString(), tasks.get(taskIndex).identify()));
                break;
            case "unmark":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }
                try {
                    taskIndex = Integer.parseInt(processedCommand[1]) - 1;
                } catch (NumberFormatException e) {
                    new DukeException();
                    break;
                }

                //Unmark task
                tasks.get(taskIndex).setIsDone(false);
                System.out.println(String.format(
                    "%s      %s", Commands.UNMARK.toString(), tasks.get(taskIndex).identify()));
                break;
            case "deadline":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                } else if (!processedCommand[1].contains("/by")) {
                    new DukeException();
                    break;
                }

                //Processing input
                String[] inputForDeadlineConstructor = processedCommand[1].split("/by", 2);
                inputForDeadlineConstructor[0] = inputForDeadlineConstructor[0].trim();
                LocalDate deadlineDate = null;
                try {
                    deadlineDate = LocalDate.parse(inputForDeadlineConstructor[1].trim());
                } catch (DateTimeParseException e) {
                    new DukeException();
                    break;
                }

                //Create deadline
                Deadline deadline = new Deadline(inputForDeadlineConstructor[0], deadlineDate);
                System.out.println(String.format(
                    "%s      %s", Commands.ADD.toString(), deadline.identify()));
                tasks.add(deadline);
                System.out.println(String.format("    Now you have %d tasks in the list.", tasks.size()));
                break;
            case "todo":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }

                //Create Todo
                ToDo todo = new ToDo(processedCommand[1]);
                System.out.println(String.format(
                    "%s      %s", Commands.ADD.toString(), todo.identify()));
                tasks.add(todo);
                System.out.println(String.format("    Now you have %d tasks in the list.", tasks.size()));
                break;
            case "event":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                } else if (!processedCommand[1].contains("/by")) {
                    new DukeException();
                    break;
                }

                //Input processing
                String[] inputForEventConstructor = processedCommand[1].split("/by", 2);
                inputForEventConstructor[0] = inputForEventConstructor[0].trim();
                LocalDate eventDate = null;
                try {
                    eventDate = LocalDate.parse(inputForEventConstructor[1].trim());
                } catch (DateTimeParseException e) {
                    new DukeException();
                    break;
                }

                //Create event
                Event event = new Event(inputForEventConstructor[0], eventDate);
                System.out.println(String.format(
                    "%s      %s", Commands.ADD.toString(), event.identify()));
                tasks.add(event);
                System.out.println(String.format("    Now you have %d tasks in the list.", tasks.size()));
                break;
            case "delete":
                //Exception catching
                if (processedCommand.length <= 1) {
                    new DukeException();
                    break;
                }
                try {
                    taskIndex = Integer.parseInt(processedCommand[1]) - 1;
                } catch (NumberFormatException e) {
                    new DukeException();
                    break;
                }

                Task deletedTask = tasks.remove((int)taskIndex);
                System.out.println(String.format(
                    "%s      %s\n    Now you have %d tasks in the list",
                    Commands.DELETE.toString(), deletedTask.identify(), tasks.size()));
                break;
            default:
                new DukeException();
            }
        }
        sc.close();
    }

Example from src/test/java/ParserTest.java lines 22-71:

    public void parse_invalidInput_dukeExceptionThrown() {
        try {
            assertEquals(" ", Parser.parseUserInput(" ", -1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("deadline", Parser.parseUserInput("deadline tmr ", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("delete", Parser.parseUserInput("delete t", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("deleted", Parser.parseUserInput("deleted 1", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("listed", Parser.parseUserInput("listed", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("event", Parser.parseUserInput("event homework /by Tmr", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }

        try {
            assertEquals("event", Parser.parseUserInput("event homework /by 202-11-10", 1).getCommand());
            fail();
        } catch (DukeException errorMessage) {
            assertEquals("    Invalid input detected. Please check your input", errorMessage.getMessage());
        }
    }

Example from src/test/java/StorageTest.java lines 50-93:

    public void updateStorage_newTaskArrayList_containTasks() {
        String filePath = "dataTest.txt";
        File file = new File(filePath);
        if (Files.exists(Paths.get(filePath))) {
            try {
                Files.delete(file.toPath());
            } catch (IOException errorMessage) {
                fail();
            }
        }

        ArrayList<Task> tasks = new ArrayList<Task>();
        tasks.add(new ToDo("sleep"));
        tasks.add(new Event("run", LocalDate.parse("2021-10-10"), null));
        tasks.add(new Event("do homework", LocalDate.parse("2021-12-05"), null));

        Storage storage = new Storage(filePath);

        try {
            storage.updateStorageFile(tasks);
        } catch (DukeException errorMessage) {
            fail();
        }

        Scanner sc = null;
        try {
            sc = new Scanner(file);
        } catch (FileNotFoundException errorMessage) {
            fail();
        }

        for (int i = 0; i < 3; i++) {
            String expectedOutput = String.format("    %s", tasks.get(i).toString());
            assertEquals(sc.nextLine().concat("\n"), expectedOutput);
        }

        sc.close();

        try {
            Files.delete(Paths.get(filePath));
        } catch (IOException errorMessage) {
            fail();
        }
    }

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: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/dukeclasses/Duke.java lines 81-86:

    /**
     * Execute methods related to the find command.
     *
     * @param command command that contains information for find command to execute.
     * @return String output that is printed in the GUI as Duke's response.
     */

Example from src/main/java/dukeclasses/Duke.java lines 95-100:

    /**
     * Execute methods related to the commands that change status of the task.
     *
     * @param command command that contains information for change of status command to execute.
     * @return String output that is printed in the GUI as Duke's response.
     */

Example from src/main/java/dukeclasses/Duke.java lines 120-125:

    /**
     * Execute methods related to the commands that deletes task.
     *
     * @param command command that contains information for delete command to execute.
     * @return String output that is printed in the GUI as Duke's response.
     */

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

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.