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

[Chua Zhong Heng] iP #63

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
cefd18d
Add Greet and Exit functions
Cazh1 Aug 31, 2023
a30a0be
Add Echo function
Cazh1 Aug 31, 2023
ff4554d
Add List and Add function
Cazh1 Sep 2, 2023
899542c
Add Mark-as-Done function
Cazh1 Sep 2, 2023
cd10722
Tweak the code to comply with coding standard
Cazh1 Sep 7, 2023
95c15bd
Update code logic to use Object Class
Cazh1 Sep 7, 2023
3d50f0a
Add tracking for types of tasks
Cazh1 Sep 7, 2023
c7b6dac
Update methods to use Object class
Cazh1 Sep 7, 2023
a5d5914
Update methods to use Object class
Cazh1 Sep 7, 2023
50f175c
Merge branch 'master' of https://github.com/Cazh1/ip
Cazh1 Sep 8, 2023
8e1aead
Refactor code
Cazh1 Sep 12, 2023
3dbdfbc
Add Error Handling function
Cazh1 Sep 12, 2023
544d7c9
Add Error Handling function
Cazh1 Sep 12, 2023
060f8b7
Revert "Add Error Handling function"
Cazh1 Sep 12, 2023
712e602
Merge branch 'master' into branch-Level-5
Cazh1 Sep 12, 2023
20a68c2
Merge pull request #1 from Cazh1/branch-Level-5
Cazh1 Sep 12, 2023
16e8cbf
Add Automated Text UI Testing
Cazh1 Sep 14, 2023
5cfdcb5
Update Exception Handler to cover more exceptions
Cazh1 Sep 15, 2023
8ff14d8
Organise files into Packages
Cazh1 Sep 15, 2023
335ff3f
Update Organization of Package
Cazh1 Sep 15, 2023
578c87e
Update Error handling code - clean up
Cazh1 Sep 15, 2023
ca8c8e3
Update Automated Text UI Testing
Cazh1 Sep 16, 2023
23dfdee
Update code with regards to TA comments
Cazh1 Sep 16, 2023
ee3e90e
Add Delete function
Cazh1 Sep 17, 2023
fe43edd
Add Save function
Cazh1 Sep 21, 2023
b7a4dd3
Update Saving capability
Cazh1 Sep 27, 2023
f583868
Merge pull request #2 from Cazh1/branch-Level-6
Cazh1 Sep 27, 2023
6b15613
Merge pull request #3 from Cazh1/branch-Level-7
Cazh1 Sep 27, 2023
4c2227f
Add import for Delete in main
Cazh1 Sep 27, 2023
0a23d97
Update previousList format
Cazh1 Sep 27, 2023
0e39d2e
Add MoreOOP for Storage and Command
Cazh1 Sep 27, 2023
e8b4ef4
Add MoreOOP for TextUi
Cazh1 Oct 2, 2023
32f1853
Add Find function
Cazh1 Oct 2, 2023
96ac6d1
Add Java Documentation
Cazh1 Oct 3, 2023
f41f811
Merge pull request #4 from Cazh1/branch-Level-9
Cazh1 Oct 3, 2023
b3bcec5
Merge pull request #5 from Cazh1/branch-JavaDoc
Cazh1 Oct 3, 2023
d0f4404
Update README.md
Cazh1 Oct 4, 2023
f6ef0c4
Update README.md
Cazh1 Oct 4, 2023
5d0ee0d
Update README.md
Cazh1 Oct 4, 2023
2ff6d44
Update README.md
Cazh1 Oct 4, 2023
9f93c2e
Update README.md
Cazh1 Oct 4, 2023
a077f54
Update README.md
Cazh1 Oct 4, 2023
bd265bb
Update README.md
Cazh1 Oct 4, 2023
e6b2f51
Update README.md
Cazh1 Oct 4, 2023
449b98d
Update README.md
Cazh1 Oct 4, 2023
bfdc87d
Update README.md
Cazh1 Oct 4, 2023
fb8bcff
Update README.md
Cazh1 Oct 4, 2023
f691c78
Update README.md
Cazh1 Oct 4, 2023
8f7dbd9
Update README.md
Cazh1 Oct 4, 2023
531399a
Update README.md
Cazh1 Oct 6, 2023
9b0876a
Update Code Quality
Cazh1 Oct 6, 2023
d17d6b4
Update README.md
Cazh1 Oct 6, 2023
7ee1694
Update Code Quality
Cazh1 Oct 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# Nuke 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.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. 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:
3. After that, locate the `src/main/java/Nuke.java` file, right-click it, and choose `Run Nuke.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
____ _
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

97 changes: 97 additions & 0 deletions src/main/java/Nuke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Nuke {

public static void printGreetingMessage() {
printLine();
System.out.println(" Hello! I'm Nuke\n" + " What can I do for you?");
printLine();
}

public static void printExitMessage() {
printLine();
System.out.println(" Bye. Hope to see you again soon!");
printLine();
}

public static void printLine() {
System.out.println(" ____________________________________________________________");
}

Choose a reason for hiding this comment

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

Can consider adding javadoc comments for each method for greater clarity.

public static void echo() {
Scanner input = new Scanner(System.in);
String item = input.nextLine();
if (item.equals("bye")) {
printExitMessage();
return;
} else {
printLine();
System.out.println(item);
printLine();
echo();

Choose a reason for hiding this comment

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

Nice!
I like that you use recursion :)

}
}

public static void dialogue(ArrayList<String> itemList, ArrayList<String> markList) {
Scanner input = new Scanner(System.in);
String item = input.nextLine();
if (item.equals("bye")) {

Choose a reason for hiding this comment

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

I like that you use else-if instead of nesting 👍

printExitMessage();
return;
} else if (item.equals("list")) {
list(itemList, markList);
} else if (item.length() > 4 && item.substring(0, 4).equals("mark")) {
String[] splitItem = item.split(" ");
int listIndex = Integer.parseInt(splitItem[1]);
mark(itemList, markList, listIndex);
} else if (item.length() > 6 && item.substring(0, 6).equals("unmark")) {
String[] splitItem = item.split(" ");

Choose a reason for hiding this comment

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

Could this array be named "items" instead?

int listIndex = Integer.parseInt(splitItem[1]);
unmark(itemList, markList, listIndex);
} else {
add(itemList, markList, item);

Choose a reason for hiding this comment

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

indentations just require one more space

}
dialogue(itemList, markList);
}

Choose a reason for hiding this comment

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

Good use of naming standards, e.g camelCase


public static void add(ArrayList<String> itemList, ArrayList<String> markList, String item) {
printLine();
itemList.add(item);
markList.add("[ ]");
System.out.printf(" added: %s\n", item);
printLine();
}

public static void list(ArrayList<String> itemList, ArrayList<String> markList) {
printLine();
System.out.println(" Here are the tasks in your list:");
for (int i = 0; i < itemList.size(); i++) {
System.out.printf(" %d.%s %s\n", i+1, markList.get(i), itemList.get(i));
}
printLine();
}

Choose a reason for hiding this comment

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

Good layout structure

public static void mark(ArrayList<String> itemList, ArrayList<String> markList, int listIndex) {
printLine();
System.out.println(" Nice! I've marked this task as done:");
markList.set(listIndex - 1, "[X]");
System.out.printf(" %s %s\n", markList.get(listIndex - 1), itemList.get(listIndex - 1));
printLine();
}

public static void unmark(ArrayList<String> itemList, ArrayList<String> markList, int listIndex) {
printLine();
System.out.println(" OK, I've marked this task as not done yet:");
markList.set(listIndex - 1, "[ ]");
System.out.printf(" %s %s\n", markList.get(listIndex - 1), itemList.get(listIndex - 1));
printLine();
}

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.

I like that your main method is short and neat :D

printGreetingMessage();
ArrayList<String> itemList = new ArrayList<String>();
ArrayList<String> markList = new ArrayList<String>();
dialogue(itemList, markList);
}
}
2 changes: 1 addition & 1 deletion text-ui-test/runtest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IF ERRORLEVEL 1 (
REM no error here, errorlevel == 0

REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
java -classpath ..\bin Nuke < input.txt > ACTUAL.TXT

REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT