Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
29a97db
Add Kowalski Class
ParthGandhiNUS Jan 21, 2024
79d3451
Add Echo Functionality
ParthGandhiNUS Jan 30, 2024
8a51274
Add functionality to list and add tasks
ParthGandhiNUS Jan 30, 2024
72d11f6
Add mark as done functionality
ParthGandhiNUS Jan 30, 2024
25ed6a7
Update code layout to follow Java coding standard
ParthGandhiNUS Feb 6, 2024
99c3382
Update functionality for Task class
ParthGandhiNUS Feb 6, 2024
125183c
Add Todo, Deadline, Event Class
ParthGandhiNUS Feb 6, 2024
985febc
Add level-4 functionalities
ParthGandhiNUS Feb 8, 2024
7aad7dd
Update code layout to follow coding standard
ParthGandhiNUS Feb 8, 2024
0c82222
Add Kowalski Exception Class
ParthGandhiNUS Feb 14, 2024
9fcbffb
Add IndexOutOfBoundsException for mark and unmark
ParthGandhiNUS Feb 14, 2024
0daa13c
Add error handling using KowalskiException
ParthGandhiNUS Feb 15, 2024
6a9de55
Merge branch 'branch-Level-5'
ParthGandhiNUS Feb 15, 2024
49a8435
Add packaging for java files
ParthGandhiNUS Feb 20, 2024
e46036a
Merge branch 'branch-A-Packages'
ParthGandhiNUS Feb 20, 2024
fac8ce4
Remove original Duke java file
ParthGandhiNUS Feb 20, 2024
5c1ccf8
Add support for deleting tasks
ParthGandhiNUS Feb 20, 2024
f81854a
Add help commands for user
ParthGandhiNUS Feb 20, 2024
623ce3a
Remove default task adder code
ParthGandhiNUS Feb 20, 2024
431ab81
Add textFileInputString methods for all tasks
ParthGandhiNUS Feb 23, 2024
7239352
Add basic write functionalities
ParthGandhiNUS Feb 24, 2024
0f62b00
Add folder creation code for text file
ParthGandhiNUS Feb 24, 2024
e6e5d36
Add saving and retrieving functionality to project
ParthGandhiNUS Feb 24, 2024
e594cc7
Merge branch 'branch-Level-6'
ParthGandhiNUS Feb 24, 2024
b44385c
Merge branch 'branch-Level-7'
ParthGandhiNUS Feb 24, 2024
ac9ed1e
Add saving functionality for delete command
ParthGandhiNUS Feb 24, 2024
2d77b06
Update documentation for functions in Kowalski bot
ParthGandhiNUS Feb 24, 2024
f47b008
Jar commit
ParthGandhiNUS Feb 24, 2024
2773484
Add new Ui class to hold all the print messages
ParthGandhiNUS Mar 5, 2024
d957c3e
Update Ui Class with more printing functions
ParthGandhiNUS Mar 5, 2024
42cb726
Refactor Kowalski.java to incorporate functions from Ui Class
ParthGandhiNUS Mar 5, 2024
8430048
Clean up Ui class and reduce magic literals
ParthGandhiNUS Mar 5, 2024
f8440df
Add printEndConversation method to Ui class
ParthGandhiNUS Mar 5, 2024
4f0fddc
Refactor Kowalski Class printIntro and printEndConversation methods
ParthGandhiNUS Mar 5, 2024
9fd02bf
Add Storage, Parser, and TaskList Class for more OOP
ParthGandhiNUS Mar 5, 2024
c844f4b
Refactor Kowalski Class to use OOP
ParthGandhiNUS Mar 5, 2024
960551a
Remove magic literals in Ui class
ParthGandhiNUS Mar 5, 2024
bf338ba
Remove magic literals in Storage Class
ParthGandhiNUS Mar 5, 2024
a7db579
Remove unnecessary constant
ParthGandhiNUS Mar 5, 2024
1cc2e52
Remove magic literals in Parser class
ParthGandhiNUS Mar 5, 2024
9b6a2d9
Sort new classes into the relevant packages
ParthGandhiNUS Mar 5, 2024
2bd8515
Refactor code to align with requirements
ParthGandhiNUS Mar 6, 2024
aa6004d
Implement findMatch method in TaskList class
ParthGandhiNUS Mar 6, 2024
882f346
Implement printMatchingTask function for TaskList Class
ParthGandhiNUS Mar 6, 2024
06b6d9c
Add Find functionalities into parseUserCommand method
ParthGandhiNUS Mar 6, 2024
257227c
Remove magic literals in TaskList Class
ParthGandhiNUS Mar 6, 2024
0458366
Merge pull request #1 from ParthGandhiNUS/branch-Level-9
ParthGandhiNUS Mar 6, 2024
6240618
Merge branch 'master' into branch-Level-9
ParthGandhiNUS Mar 6, 2024
ea0db83
Add JavaDoc for Kowalski Class
ParthGandhiNUS Mar 6, 2024
b2fd792
Add JavaDoc for the different Task classes
ParthGandhiNUS Mar 6, 2024
d188010
Update JavaDoc for TaskList Class
ParthGandhiNUS Mar 6, 2024
1afcfa5
Update JavaDoc for method parseUserCommand in Parser Class
ParthGandhiNUS Mar 6, 2024
b12bf13
Update JavaDoc for Storage Class
ParthGandhiNUS Mar 6, 2024
5e2b8da
Merge pull request #2 from ParthGandhiNUS/branch-A-JavaDoc
ParthGandhiNUS Mar 6, 2024
a5a2dd6
Update main README.md file to include a picture of Kowalski
ParthGandhiNUS Mar 6, 2024
187e8fc
Update Kowalski.txt
ParthGandhiNUS Mar 6, 2024
0581953
Include missing UI.printDivider method in parseUserCommand method
ParthGandhiNUS Mar 6, 2024
04ffa8a
Update docs/README.md with User Guide
ParthGandhiNUS Mar 6, 2024
a77e317
Add missing spacing
ParthGandhiNUS Mar 6, 2024
665139d
Update README.md
ParthGandhiNUS Mar 6, 2024
73eac78
Edit README.md
ParthGandhiNUS Mar 6, 2024
9cca73a
Merge branch 'branch-Level-9'
ParthGandhiNUS Mar 8, 2024
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
14 changes: 14 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class Deadline extends Task {

protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
15 changes: 15 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Event extends Task {
protected String startDayAndTime;
protected String endDayAndTime;

public Event (String description, String startDayAndTime, String endDayAndTime) {
super(description);
this.startDayAndTime = startDayAndTime;
this.endDayAndTime = endDayAndTime;
}

@Override
public String toString() {
return "[E]" + super.toString() + " (from: " + startDayAndTime + " to: " + endDayAndTime + ")";
}
}
255 changes: 255 additions & 0 deletions src/main/java/Kowalski.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
import java.util.Scanner;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

overall good use of javadoc comments

import java.util.ArrayList;
import java.util.List;
import java.util.InputMismatchException;


public class Kowalski {

private static final String DIVIDING_LINE = "____________________________________________________________";

public static List <Task> currentTask = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Plural form should be used on names representing a collection of objects.

https://se-education.org/guides/conventions/java/basic.html#naming

public static Scanner in = new Scanner (System.in);

/**
* Prints out the message introducing the functionalities of Kowalski Bot
*/
public static void printIntro(){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

printIntro() {
maintain spacing consistently in classes and methods

System.out.println(DIVIDING_LINE);
System.out.println("Welcome Skipper! I'm Kowalski, reporting for Duty!" + System.lineSeparator() +
"What can I do for you today?" );
System.out.println(DIVIDING_LINE);
}

/**
* Used to check if the user has accurately input the deadline by stating the "/by"
* @param deadlineDetails : Contains the details of the deadline task
* @throws KowalskiException In the event that the input has no "/by"
*/
public static void checkDeadlineInput(String deadlineDetails) throws KowalskiException{
if (!(deadlineDetails.contains("/by"))) {
throw new KowalskiException();
}
}

/**
* Used to check if the user has accurately input the deadline by stating the "/from" and "/to"
* @param eventDetails : Contains the details of the event task
* @throws KowalskiException In the event that the input has no "/from" or "/to" or both
*/
public static void checkEventInput(String eventDetails) throws KowalskiException{
if (!((eventDetails.contains("/from")) && (eventDetails.contains("/to")))) {
throw new KowalskiException();
}
}

/**
* Used to process the different variations of the users inputs
* @param userInput : String which the user inputs
* @return String which is in lowercase and clear of any unnecessary whitespace
*/
public static String processInput(String userInput){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use the name to explain what the function does. perhaps you could name it trimAndMakeLowerCase() instead?
https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#use-name-to-explain

return (userInput.trim()).toLowerCase();
}

/**
* Prints out an accurate message for the number of tasks in the list.
* @param number : represents the total current task count
*/
public static void printCurrentTaskMessage(int number){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the name number is not very descriptive, you can call is taskNumber instead ?

https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#use-name-to-explain

switch (number){
case 0:
System.out.println("Now you have 0 tasks in the list.");
break;
case 1:
System.out.println("Now you have 1 task in the list.");
break;
default:
System.out.println("Now you have " + number + " tasks in the list.");
}
}

/**
* Used in the "list" command to print all the Current Tasks in the proper format
*/
public static void printCurrentTaskItems(){
for (int i = 1; i <= currentTask.size(); i++){
System.out.println(i + "." + currentTask.get(i-1));
}
}

/**
* Cleans up the user input and forms new Deadline Task
* @param deadlineDetails : User input for details of the deadline task
* @return new deadline task created
*/
private static Task getNewDeadlineTask(String deadlineDetails) {
String[] deadlineArray = deadlineDetails.split("/by");
for (int i = 0; i < deadlineArray.length; i++) {
deadlineArray[i] = deadlineArray[i].trim();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove one empty line (unnecessary whitespace)


return new Deadline(deadlineArray[0], deadlineArray[1]);
}


/**
* Cleans up the user input and forms new event Task
* @param eventDetails : User input for details of the event task
* @return new event task created
*/
private static Task getNewEventTask(String eventDetails) {
String[] eventArray = eventDetails.split("/from");
String eventInformation = eventArray[0].trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

String [] fromAndTo = eventArray[1].split("/to");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

array specifiers should be attached to the type
https://se-education.org/guides/conventions/java/basic.html#types

String eventFrom = fromAndTo[0].trim();
String eventTo = fromAndTo[1].trim();

return new Event(eventInformation, eventFrom, eventTo);
}

/**
* Processes all the inputs from the user and categorises the User Commands
* @param UserCommand: The first word input by the user
*/
public static void parseUserCommand(String UserCommand) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this function is very long (>>30 LOC). consider separating the code into multiple functions

https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#avoid-long-methods


int taskNumber;
int lastTaskIndex;
String remainingCommand;

switch (UserCommand){
case "bye":
break;

case "list":

printCurrentTaskItems();
System.out.println(DIVIDING_LINE);
break;

case "unmark":
try {
taskNumber = in.nextInt();
} catch (InputMismatchException e) {
System.out.println("Skipper input a god damn number! I am now gonna add the text which you inputted into our list!");
break;
}

try{
currentTask.get(taskNumber - 1).markAsNotDone();
System.out.println( "C'mon Skipper, you're much better than that! I've marked this task as undone:");
System.out.println(" " + currentTask.get(taskNumber - 1));
} catch (IndexOutOfBoundsException e) {
System.out.println("Invalid Task Number! Skipper stop acting like Private!");
}
System.out.println(DIVIDING_LINE);
break;

case "mark":
try {
taskNumber = in.nextInt();
} catch (InputMismatchException e) {
System.out.println("Skipper input a god damn number! I am now gonna add the text which you inputted into our list!");
break;
}

try{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

spacing try {

currentTask.get(taskNumber - 1).markAsDone();
System.out.println( "Way to go Skipper! I've marked this task as done:");
System.out.println(" " + currentTask.get(taskNumber - 1));
} catch (IndexOutOfBoundsException e) {
System.out.println("Invalid Task Number! Skipper stop acting like Private!");
}
System.out.println(DIVIDING_LINE);
break;

case "todo":
String toDoDetails = in.nextLine();

Task newToDoTask = new Todo(toDoDetails.trim());
currentTask.add(newToDoTask);
lastTaskIndex = currentTask.size() - 1;

System.out.println("Skipper you've got this work to do:");
System.out.println(" " + currentTask.get( lastTaskIndex));
printCurrentTaskMessage(currentTask.size());
System.out.println(DIVIDING_LINE);
break;

case "deadline":
String deadlineDetails = in.nextLine();

try{
checkDeadlineInput(deadlineDetails);

//Adding the new deadline task into currentTask List after processing and cleaning inputs
Task newDeadlineTask = getNewDeadlineTask(deadlineDetails);
currentTask.add(newDeadlineTask);
lastTaskIndex = currentTask.size() - 1;

//Printing the appropriate information for the User
System.out.println("Skipper, I have recorded this deadline:");
System.out.println(" " + currentTask.get( lastTaskIndex));
printCurrentTaskMessage(currentTask.size());
System.out.println(DIVIDING_LINE);
} catch (KowalskiException e){
System.out.println("Skipper your inputs are wrong! Try again!");
System.out.println(DIVIDING_LINE);
}
break;

case "event":
String eventDetails = in.nextLine();

try{
checkEventInput(eventDetails);

//Adding the new event task into currentTask List after processing and cleaning inputs
Task newEventTask = getNewEventTask(eventDetails);
currentTask.add(newEventTask);
lastTaskIndex = currentTask.size() - 1;

//Printing the appropriate information for the User
System.out.println("Skipper I've noted this event in my calendar:");
System.out.println(" " + currentTask.get(lastTaskIndex));
printCurrentTaskMessage(currentTask.size());
System.out.println(DIVIDING_LINE);
} catch (KowalskiException e) {
System.out.println("Skipper your inputs are wrong! Try again!");
System.out.println(DIVIDING_LINE);
}
break;


default:
remainingCommand = in.nextLine();
Task newTask = new Task(UserCommand + remainingCommand);
currentTask.add(newTask);
System.out.println("added: " + UserCommand + remainingCommand);
System.out.println(DIVIDING_LINE);
break;
}
}

/**
* Prints out the message to end conversation with the user
*/
public static void printEndConversation(){
System.out.println("Bye Skipper! Hope to serve you again for your next mission!");
System.out.println(DIVIDING_LINE);
}

public static void main(String[] args){
printIntro();
String userCommand = processInput(in.next());

while (!(userCommand.equals("bye"))){
parseUserCommand(processInput(userCommand));
userCommand = in.next();
}

printEndConversation();
}
}
2 changes: 2 additions & 0 deletions src/main/java/KowalskiException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public class KowalskiException extends Exception{
}
32 changes: 32 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

public String getDescription() {
return description;
}

public String getStatusIcon() {

return (isDone ? "X" : " "); // mark done task with X
}

public void markAsNotDone(){

this.isDone = false;
}
public void markAsDone(){

this.isDone = true;
}

@Override
public String toString() {
return "[" + getStatusIcon() + "] " + getDescription();
}
}
11 changes: 11 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Todo extends Task {

public Todo(String description){
super(description);
}

@Override
public String toString() {
return "[T]" + super.toString();
}
}