Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d411f2a
Add pull request 1
karishma-t Sep 7, 2023
758863c
Add Level-0 - Rename, Greet, Exit.
karishma-t Sep 7, 2023
3115910
Add Level 1 echo
karishma-t Sep 7, 2023
d97f8cf
Add level-2
karishma-t Sep 7, 2023
4a96d47
Add level-3
karishma-t Sep 7, 2023
2b5ef00
Add level-4
karishma-t Sep 15, 2023
3edf721
Add error handling and exceptions
karishma-t Oct 3, 2023
98652d7
Add Level-6
karishma-t Oct 4, 2023
eb53e6c
A-CodingStandard
karishma-t Oct 4, 2023
92d18e3
Add Level-7
karishma-t Oct 4, 2023
a362da3
Add A-Jar
karishma-t Oct 4, 2023
9063cb1
Add Classes
karishma-t Oct 5, 2023
846da7b
Add support for saving dates
karishma-t Oct 5, 2023
199eacc
Add Level-9
karishma-t Oct 5, 2023
dbb8e86
Add Javadoc
karishma-t Oct 5, 2023
6c3d74d
Merge pull request #1 from karishma-t/branch-Level-9
karishma-t Oct 5, 2023
2d3ddff
Add User Guide for chatbot
karishma-t Oct 5, 2023
ec4f1a2
Add feature summary to readme
karishma-t Oct 5, 2023
d74c4c6
Merge pull request #2 from karishma-t/branch-A-JavaDoc
karishma-t Oct 5, 2023
3ae016a
Add comments for main
karishma-t Oct 6, 2023
0ddd375
Add class for exception
karishma-t Oct 6, 2023
fa5d740
Update README.md
karishma-t Oct 9, 2023
1b9e891
Add classes for commands and add unmark task
karishma-t Oct 24, 2023
ac6605a
Add class for AddComand and modify parser
karishma-t Oct 24, 2023
51df475
Add checks for empty event/deadline dates
karishma-t Oct 25, 2023
2b9826e
Add common check for mark/unmark
karishma-t Oct 25, 2023
c9f2dc5
Modify delete command
karishma-t Oct 25, 2023
3313f0d
Modify readme
karishma-t Oct 25, 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
1 change: 1 addition & 0 deletions pullreq1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pull request 1
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

75 changes: 75 additions & 0 deletions src/main/java/Ken.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

import java.util.Scanner;

public class Ken {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

//Initialise array to store tasks
String[] tasks = new String[100];
boolean[] taskStatus = new boolean[100]; // true for done, false for not done

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this variable name sound more like a boolean? for example: isDone

int taskCount = 0;

// Print the initial message
System.out.println(" ____________________________________________________________");
System.out.println(" Hello! I'm Ken");
System.out.println(" What dyu want?");
System.out.println("____________________________________________________________");

// Read and echo user commands until "bye" is entered
while (true) {
String userInput = scanner.nextLine();

// Echo the user's command
System.out.println(" ____________________________________________________________");


// Check if the user wants to exit

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job on leaving comments with same indentation

if (userInput.equalsIgnoreCase("bye")) {
System.out.println("____________________________________________________________");
System.out.println(" Bye then!");
System.out.println("____________________________________________________________");
break; // Exit the loop
} else if (userInput.equalsIgnoreCase("list")) {
System.out.println(" Tasks ");
for (int i = 0; i < taskCount; i++) {
char statusSymbol = taskStatus[i] ? 'X' : ' ';
System.out.println(" " + (i + 1) + ".[" + statusSymbol + "] " + tasks[i]); }
} else if (userInput.startsWith("mark " )) {
try {
int taskIndex = Integer.parseInt(userInput.substring(5).trim()) - 1;
if (taskIndex >= 0 && taskIndex < taskCount) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe you can break the code up into different functions for better readability

taskStatus[taskIndex] = true;
System.out.println(" Nice! I've marked this task as done:");
System.out.println(" [X] " + tasks[taskIndex]);
} else {
System.out.println(" Task not found. Please provide a valid task number.");
}
} catch (NumberFormatException e) {
System.out.println(" Invalid input. Please provide a valid task number.");
}
} else if (userInput.startsWith("unmark ")) {
try {
int taskIndex = Integer.parseInt(userInput.substring(7).trim()) - 1;
if (taskIndex >= 0 && taskIndex < taskCount) {
taskStatus[taskIndex] = false;
System.out.println(" OK, I've marked this task as not done yet:");
System.out.println(" [ ] " + tasks[taskIndex]);
} else {
System.out.println(" Task not found. Please provide a valid task number.");
}
Comment on lines +52 to +62

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe you can add some comments to make it easier to read and understand :)

} catch (NumberFormatException e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job on format of try-catch statements

System.out.println(" Invalid input. Please provide a valid task number.");
}
}
else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this else be on the previous line? eg: } else {

//Add task to the array
tasks[taskCount] = userInput;
taskCount++;
System.out.println(" added: " + userInput);
}
}
// Close the scanner when done
scanner.close();
}
}