Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
cfa100b
Change the dukes speech
Sep 1, 2021
58398a4
Add a echo functions that repeat commands entered by the user and exi…
Sep 1, 2021
7b1d074
Add the ability to store text input into a list and display it back w…
Sep 1, 2021
1d74b39
Add the ability to mark task as done
Sep 1, 2021
eed209d
Add catergory to the task, todo,deadlines and events
Sep 2, 2021
f4fecb4
Refactor the code to remove duplcated functions
Sep 4, 2021
b8ad62d
Added the ability to add mutiple task in the same line and the abilit…
Sep 5, 2021
37abf0d
Added a way to print words like what was printed for duke but based o…
Sep 5, 2021
1e6963b
Added testing
Sep 6, 2021
2f491b7
Add a lot of exceptions to prevent any errors
Sep 6, 2021
4a08901
Changing some Strings
Sep 6, 2021
50ed25d
Further fixes to the String printed
Sep 6, 2021
64b7752
Merge branch 'branch-Level-5'
Sep 7, 2021
2305316
Minimal packaging
Sep 7, 2021
57771c8
More packages
Sep 7, 2021
a9d7713
Fix packages
Sep 7, 2021
1a2a6ac
Merge branch 'branch-A-Packages'
Sep 7, 2021
c383114
Add a delete function to class ListManager and class inputhandler whe…
Sep 15, 2021
5ee47d4
Some formatting words changes
Sep 15, 2021
6ee2be3
Add the save function to txt files
Sep 15, 2021
f714fce
Merge branch 'branch-Level-7'
Sep 15, 2021
ec11a9f
remove some bugged files
Sep 15, 2021
6d21d77
debugging the file update when there is no task in the array
Sep 15, 2021
8565495
Change all the commands into their own class
Sep 25, 2021
80e1c4e
Added a find date command that find task with a specific date
Sep 26, 2021
71fb4c5
Added Find Keyword to search the list
Sep 27, 2021
cf3394a
Merge pull request #1 from kum-wh/branch-Level-8
kum-wh Sep 28, 2021
3f53d4e
Merge pull request #2 from kum-wh/branch-Level-9
kum-wh Sep 28, 2021
30a5c96
Added Comment to All function and classes
Sep 28, 2021
1f8f273
Merge branch 'master' of https://github.com/kum-wh/ip
Sep 28, 2021
4fb78e6
Merge pull request #3 from kum-wh/branch-A-JavaDoc
kum-wh Sep 28, 2021
05c358f
Merge branch 'branch-A-JavaDoc'
Sep 28, 2021
9a88e1b
Level-8
Sep 28, 2021
668659b
Level-9
Sep 28, 2021
8c59d4d
JavaDoc
Sep 28, 2021
9060af4
no message
Sep 28, 2021
dc1ab66
Merge branch 'branch-A-JavaDoc'
Sep 28, 2021
2b9947c
Merge commit '668659beb25f93f3be1f67d4b3ea7b0d964ae7b9'
Sep 28, 2021
6ca401f
Merge commit '9a88e1b9b936bff54c9ed02dbd7763db87c9cd6b'
Sep 28, 2021
27f1319
Merge branch 'master' of https://github.com/kum-wh/ip
Sep 28, 2021
1c84ea0
Levvel-7 fix
Sep 28, 2021
899cb14
Merge branch 'branch-Level-7'
Sep 28, 2021
1915741
Level-8-fix
Sep 28, 2021
2bb73dd
Level9 fix
Sep 28, 2021
88be32e
A-JavaDoc
Sep 28, 2021
6ffc9fd
Merge pull request #4 from kum-wh/branch-Level-8
kum-wh Sep 28, 2021
fd4bc0a
Merge branch 'master' into branch-Level-9
kum-wh Sep 28, 2021
125df38
Merge pull request #5 from kum-wh/branch-Level-9
kum-wh Sep 28, 2021
2ecd0a6
Merge branch 'master' into branch-A-JavaDoc
kum-wh Sep 28, 2021
d22def0
Merge pull request #6 from kum-wh/branch-A-JavaDoc
kum-wh Sep 28, 2021
5d5f795
Merge branch 'master' of https://github.com/kum-wh/ip
Sep 28, 2021
1bbc6f5
Level8
Sep 28, 2021
7022461
Level9
Sep 28, 2021
78d2e29
JavaDoc
Sep 28, 2021
15cfa13
Branch level8
Sep 28, 2021
b349f2e
Branch Level9
Sep 28, 2021
6a5eff9
A-JavaDoc
Sep 28, 2021
0303cbe
Merge pull request #7 from kum-wh/branch-Level-8
kum-wh Sep 28, 2021
52b947b
Merge branch 'master' into branch-Level-9
kum-wh Sep 28, 2021
b097c6f
Merge pull request #8 from kum-wh/branch-Level-9
kum-wh Sep 28, 2021
025d7c0
Merge branch 'master' into branch-A-JavaDoc
kum-wh Sep 28, 2021
c922374
Merge pull request #9 from kum-wh/branch-A-JavaDoc
kum-wh Sep 28, 2021
ecceb76
Level:8
Sep 28, 2021
8e59389
Level:9
Sep 28, 2021
887ddf1
A-JavaDoc
Sep 28, 2021
b184fca
Merge pull request #10 from kum-wh/branch-Level-8
kum-wh Sep 28, 2021
2989450
Merge branch 'branch-A-JavaDoc'
Sep 28, 2021
d07b2aa
Solving merge conflict
Sep 28, 2021
bd7aca4
Merge branch 'branch-Level-9'
Sep 28, 2021
f3317e1
Merging PRS
Sep 28, 2021
264344e
Fix Exception Messages and add more comments to functions
Sep 29, 2021
21ea138
Fix a bug that invalid date keep throwing parsing error
Sep 29, 2021
19b892c
Update README.md
kum-wh Sep 29, 2021
8e97fa8
Set theme jekyll-theme-cayman
kum-wh Sep 29, 2021
41d7353
Update README.md
kum-wh Sep 29, 2021
5d3bffc
Create README.md
kum-wh Sep 29, 2021
4339745
Update README.md
kum-wh Sep 29, 2021
7576a85
Update README.md
kum-wh Sep 29, 2021
3f424fc
Update README.md
kum-wh Sep 29, 2021
5cbdada
Update README.md
kum-wh Sep 30, 2021
0ec1b61
Update README.md
kum-wh Sep 30, 2021
28c7be4
Update README.md
kum-wh Sep 30, 2021
e4d14a7
Update README.md
kum-wh Sep 30, 2021
4054b00
Update README.md
kum-wh Sep 30, 2021
bc4554c
Update README.md
kum-wh Sep 30, 2021
1816abe
Update README.md
kum-wh Sep 30, 2021
e29bcf7
Update README.md
kum-wh Sep 30, 2021
cee51f8
Update README.md
kum-wh Sep 30, 2021
bba48ca
Fix ArtBot null pointer
Sep 30, 2021
f2c2a13
Merge branch 'master' of https://github.com/kum-wh/ip
Sep 30, 2021
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
Empty file added data/duke.txt
Empty file.
4 changes: 4 additions & 0 deletions duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[T];[X];watch hankyuu livestream
[T];[ ];watch haxxnini livestream
[D];[X];reach radiant;this season
[E];[ ]g2 vs sentinel;12am
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: duke.Duke

154 changes: 154 additions & 0 deletions src/main/java/duke/ArtBot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package duke;

import java.util.ArrayList;

public class ArtBot implements ArtInterface{

private final String userInput;

public ArtBot(String userInput){
this.userInput = userInput;
}

private String[] getLogo(String letter){
String[] letterArt;
switch(letter) {
case "A":
letterArt = Logo.A.split("\n");
break;
case "B":
letterArt = Logo.B.split("\n");
break;
case "C":
letterArt = Logo.C.split("\n");
break;
case "D":
letterArt = Logo.D.split("\n");
break;
case "E":
letterArt = Logo.E.split("\n");
break;
case "F":
letterArt = Logo.F.split("\n");
break;
case "G":
letterArt = Logo.G.split("\n");
break;
case "H":
letterArt = Logo.H.split("\n");
break;
case "I":
letterArt = Logo.I.split("\n");
break;
case "J":
letterArt = Logo.J.split("\n");
break;
case "K":
letterArt = Logo.K.split("\n");
break;
case "L":
letterArt = Logo.L.split("\n");
break;
case "M":
letterArt = Logo.M.split("\n");
break;
case "N":
letterArt = Logo.N.split("\n");
break;
case "O":
letterArt = Logo.O.split("\n");
break;
case "P":
letterArt = Logo.P.split("\n");
break;
case "Q":
letterArt = Logo.Q.split("\n");
break;
case "R":
letterArt = Logo.R.split("\n");
break;
case "S":
letterArt = Logo.S.split("\n");
break;
case "T":
letterArt = Logo.T.split("\n");
break;
case "U":
letterArt = Logo.U.split("\n");
break;
case "V":
letterArt = Logo.V.split("\n");
break;
case "W":
letterArt = Logo.W.split("\n");
break;
case "X":
letterArt = Logo.X.split("\n");
break;
case "Y":
letterArt = Logo.Y.split("\n");
break;
case "Z":
letterArt = Logo.Z.split("\n");
break;
case "0":
letterArt = Logo.ZERO.split("\n");
break;
case "1":
letterArt = Logo.One.split("\n");
break;
case "2":
letterArt = Logo.Two.split("\n");
break;
case "3":
letterArt = Logo.THREE.split("\n");
break;
case "4":
letterArt = Logo.FOUR.split("\n");
break;
case "5":
letterArt = Logo.FIVE.split("\n");
break;
case "6":
letterArt = Logo.SIX.split("\n");
break;
case "7":
letterArt = Logo.SEVEN.split("\n");
break;
case "8":
letterArt = Logo.EIGHT.split("\n");
break;
case "9":
letterArt = Logo.NINE.split("\n");
break;
default:
letterArt = null;
break;
}
return letterArt;
}

public void drawArt() throws CommandException{
String[] charArray = userInput.split("(?!^)");
ArrayList<String[]> artArray = new ArrayList<>();
String[] mergeString = new String[5];
for(String s:charArray){
String[] letterInArtForm = getLogo(s);
if(letterInArtForm == null){
throw new CommandException(ErrorList.ERROR_LETTER_NOT_FOUND);
}
artArray.add(letterInArtForm);
}
for(int i = 0; i < 5; i++){
StringBuilder sb = new StringBuilder();
for (String[] strings : artArray) {
String temp = strings[i];
sb.append(temp);
}
mergeString[i] = sb.toString();
}
for(int i = 0; i < 5; i++){
System.out.println(mergeString[i]);
}
}
}
5 changes: 5 additions & 0 deletions src/main/java/duke/ArtInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package duke;

public interface ArtInterface {
void drawArt() throws CommandException;
}
14 changes: 14 additions & 0 deletions src/main/java/duke/CommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package duke;

public class CommandException extends Exception{

private String errorMessage;

public CommandException(String errorMessage){
this.errorMessage = errorMessage;
}

public void handleException(){
System.out.println(errorMessage);
}
}
5 changes: 5 additions & 0 deletions src/main/java/duke/CommandInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package duke;

public interface CommandInterface {
void handleCommand();
}
61 changes: 61 additions & 0 deletions src/main/java/duke/CommandManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package duke;

public class CommandManager implements CommandInterface{

private static final String COMMAND_HELP = "!help";
private static final String COMMAND_LIST_HELP = "!list";
private static final String COMMAND_EVENT_HELP = "!event";
private static final String COMMAND_DEADLINE_HELP = "!deadline";
private static final String COMMAND_ECHO = "!echo";
private static final String MESSAGE_HELP = "List of Commands:\n" +
" echo - Repeat whatever was typed - !echo to repeat in art form\n" +
" list - Display List - !list for details\n" +
" todo - Add ToDo Task\n" +
" event - Add Event Task - !event for details\n" +
" deadline - Add Deadline Task - !deadline for details\n" +
" bye - Shut Down\n";
private static final String MESSAGE_LIST_HELP = "list displays all tasks\n" +
"list todo displays all todo tasks\n" +
"list event displays all event tasks\n" +
"list deadline displays all deadline tasks\n";
private static final String MESSAGE_EVENT_HELP = "event command requires a timing indicated using \"at\" [timing]\n";
private static final String MESSAGE_DEADLINE_HELP = "deadline command requires a end time indicated using \"by\"[end time]\n";

private final String description;

public CommandManager(String description){
this.description = description;
}

private void handleArtCommand(){
String removeCommand = description.replaceFirst(COMMAND_ECHO,"").trim().toUpperCase();
System.out.println(removeCommand);
ArtBot artBot = new ArtBot(removeCommand);
try {
artBot.drawArt();
}catch (CommandException e){
e.handleException();
}
}

public void handleCommand(){
if(description.startsWith(COMMAND_ECHO)){
handleArtCommand();
return;
}
switch(description) {
case COMMAND_HELP:
System.out.println(Logo.divider + MESSAGE_HELP + Logo.dividerWithoutNewLine);
break;
case COMMAND_LIST_HELP:
System.out.println(Logo.divider + MESSAGE_LIST_HELP + Logo.dividerWithoutNewLine);
break;
case COMMAND_EVENT_HELP:
System.out.println(Logo.divider + MESSAGE_EVENT_HELP + Logo.dividerWithoutNewLine);
break;
case COMMAND_DEADLINE_HELP:
System.out.println(Logo.divider + MESSAGE_DEADLINE_HELP + Logo.dividerWithoutNewLine);
break;
}
}
}
52 changes: 52 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package duke;

import duke.task.Task;

import java.util.Scanner;
import java.util.ArrayList;

public class Duke {
private static final String MESSAGE_HI = "Hello! I'm Duke\n" + "What can I do for you?\n" + "!help for Command List\n";
private static final String MESSAGE_BYE = "Bye. Hope to see you again soon!\n";

protected static boolean isOnline;

private static void startDuke(){
isOnline = true;
System.out.println(Logo.logo +Logo.divider + MESSAGE_HI + Logo.dividerWithoutNewLine);
}

private static void endDuke(){
System.out.println(Logo.divider + MESSAGE_BYE + Logo.divider + Logo.bye);
}

public static void main(String[] args) {
startDuke();
Scanner in = new Scanner(System.in);
ArrayList <Task> list = new ArrayList<>();
ListManager listManager = new ListManager(list);
FileManager fileManager = new FileManager(listManager);
fileManager.covertStringToTask();
while(isOnline) {
String userInput = in.nextLine().toLowerCase().trim();
if (userInput.startsWith("!")) {

Choose a reason for hiding this comment

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

perhaps a magic string here? maybe change to a named constant in case you are going to use it somewhere else...

CommandManager commandManager = new CommandManager(userInput);
commandManager.handleCommand();
} else {
InputHandler inputManager = new InputHandler(userInput, listManager, fileManager);
try {
inputManager.handleInput();
}catch(CommandException e){
e.handleException();
}
if(list.size() != 0) {
fileManager.writeToFile(list.get(0), false);
for (int i = 1; i < list.size(); i++) {
fileManager.writeToFile(list.get(i), true);
}
}
}
}
endDuke();
}
}
20 changes: 20 additions & 0 deletions src/main/java/duke/ErrorList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package duke;

public class ErrorList {
public static final String ERROR_NULL = "☹ OOPS!!! Input cannot be empty.";
public static final String ERROR_UNKNOWN_COMMAND = "☹ OOPS!!! I'm sorry, but I don't know what that means :-(\n" + "" +
"Defaulting to Echo. Type !help to see the list of Commands";
public static final String ERROR_EMPTY_LIST = "☹ OOPS!!! List is empty. Add tasks to the list.";
public static final String ERROR_EMPTY_TODO_LIST = "☹ OOPS!!! There is no To Do task in list. Add To Do tasks to the list.";
public static final String ERROR_EMPTY_EVENT_LIST = "☹ OOPS!!! There is no Event task in list. Add Events to the list.";
public static final String ERROR_EMPTY_DEADLINE_LIST = "☹ OOPS!!! There is no Deadline task in list. Add Deadlines to the list.";
public static final String ERROR_EMPTY_TODO_INPUT = "☹ OOPS!!! The description of a todo cannot be empty.\n";
public static final String ERROR_EMPTY_EVENT_INPUT = "☹ OOPS!!! The description of a event cannot be empty.\n";
public static final String ERROR_EMPTY_DEADLINE_INPUT = "☹ OOPS!!! The description of a deadline cannot be empty.\n";
public static final String ERROR_EMPTY_ECHO_INPUT = "☹ OOPS!!! The description of a echo cannot be empty.\n";
public static final String ERROR_EMPTY_EVENT_TIME = "☹ OOPS!!! The timing of a event cannot be empty.\n";
public static final String ERROR_EMPTY_DEADLINE_TIME = "☹ OOPS!!! The due date of a deadline cannot be empty.\n";
public static final String ERROR_DONE_TASK_NOT_IN_LIST ="☹ OOPS!!! Task done not found in list\n";
public static final String ERROR_DELETE_TASK ="☹ OOPS!!! Cannot remove task that does not exist.\n";
public static final String ERROR_LETTER_NOT_FOUND = "☹ OOPS!!! Something went wrong. Do not input space or symbols.\n";
}
Loading