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

Level 1 to 3 (Week 2) #1

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
3b19ba1
Add Gradle support
May 24, 2020
269e3ff
Level 1 to 3
tototto Aug 15, 2020
0f09980
Finished Level 4
tototto Aug 22, 2020
d20f84a
A-TextUiTesting
tototto Aug 28, 2020
eeb75ba
A-CodingStandard
tototto Aug 28, 2020
5d75ff9
branch-Level-5
tototto Aug 29, 2020
f6cdbf9
Merge tag 'branch-Level-5'
tototto Aug 29, 2020
c5d61c0
Made Task abstract
Aug 29, 2020
9624640
Merge A-AbstractClasses increment with Master
Aug 29, 2020
a75fcee
build.gradle: Update version to 8.29
Aug 29, 2020
61b84e7
Completed A-CodeQuality
Aug 30, 2020
fe09317
Merging branch-A-CodeQuality with Master
Aug 30, 2020
dc20b21
created Packages for Duke and re-solved Shell Script issues for Testing
Aug 30, 2020
73953a7
Merged branch-A-Packages with Master
Aug 30, 2020
1be5731
completed branch-Level-6
Sep 4, 2020
365f5a8
Merge pull request #1 from tototto/branch-Level-6
tototto Sep 4, 2020
7a2fa8a
branch-Level-7 added File IO operation
Sep 6, 2020
2ee965d
added demonstration of using displayHandler to print messages for Rea…
Sep 6, 2020
a28ce65
branch-A-JavaDoc added some java docs
Sep 6, 2020
4e3bb94
Merge branch 'branch-Level-7'
Sep 6, 2020
00f14ef
completed A-MoreOOP, refactored code out to individual classes/compon…
Sep 12, 2020
1471017
completed branch-Level-9
Sep 12, 2020
4578c64
add Junit testcases
Sep 12, 2020
7c0bebd
Merge pull request #2 from tototto/branch-A-JUnit
tototto Sep 12, 2020
02fc569
resolve merge conflict when merging master to branch-Level-9
Sep 12, 2020
cbe13a9
Merge pull request #3 from tototto/branch-Level-9
tototto Sep 12, 2020
a1a2066
commiting
Sep 12, 2020
fd6ead5
resolved local merge conflict with the version from Git Pull
Sep 12, 2020
ef20fc2
Created User Guide
tototto Sep 18, 2020
9991603
Changed format
tototto Sep 18, 2020
bd7293b
Update README.md
tototto Sep 18, 2020
7adebbe
Set theme jekyll-theme-slate
tototto Sep 18, 2020
0bea941
Update README.md
tototto Sep 19, 2020
f134e03
Update README.md
tototto Sep 28, 2020
d54b09a
add gradle support from upstream
Jan 19, 2021
673a84c
Merge branch 'branch-A-Gradle'
Jan 19, 2021
839b98c
Merge branch 'master' of https://github.com/tototto/ip
Jan 19, 2021
9c940b8
introduced JavaFX
Jan 24, 2021
859a1bc
Implement working JavaFX UI
Jan 26, 2021
1ec8b9a
competed working JavaFX for Duke
Jan 27, 2021
8d1655d
Finish building FXML
Jan 27, 2021
0ec3d22
refactor into packages of FXML implementation
Jan 28, 2021
a7badc2
Merge branch 'branch-Level-10'
Jan 28, 2021
c349451
attempted to improve coding standard
Jan 29, 2021
fe0fd54
added A Stricter Coding Standard
Jan 29, 2021
1250f58
Create yml file for CI
tototto Jan 31, 2021
5848c81
fixed yml syntax
tototto Jan 31, 2021
76b918f
added an extension from category C (C-Help)
Jan 31, 2021
bb13edd
Merge branch 'master' of https://github.com/tototto/ip
Jan 31, 2021
b537754
updated checkstyle.xml to remove suppresion filter dependency
Jan 31, 2021
dd66300
added suppresion filter dependency back and created suppression.xml
Jan 31, 2021
b72459a
fixed checkstyle in FileManager
Jan 31, 2021
897efa7
fixed remaning checkstyle error found in CI
Jan 31, 2021
1d01229
pushing code with junit issue to repo so others can take a look
Jan 31, 2021
6cb4a7a
fixed issue where project cannot build Junit using Gradle
Jan 31, 2021
c3ebc0c
fixed checkstyle for Junit
Jan 31, 2021
0146c6b
Update README.md
tototto Feb 5, 2021
456113a
Update README.md
tototto Feb 5, 2021
db1c81f
Update README.md
tototto Feb 5, 2021
3c390c0
Update README.md
tototto Feb 5, 2021
e0a403d
Set theme jekyll-theme-merlot
tototto Feb 12, 2021
25c4f7f
Create UserGuide.md
tototto Feb 12, 2021
d64cd84
Create DeveloperGuide.md
tototto Feb 12, 2021
c53b4b1
Update UserGuide.md
tototto Feb 12, 2021
f106611
Update README.md
tototto Feb 12, 2021
6ddfe40
Update README.md
tototto Feb 12, 2021
52be408
Update UserGuide.md
tototto Feb 12, 2021
bab01ec
Create image
tototto Feb 13, 2021
dd338ae
Add files via upload
tototto Feb 13, 2021
378bdd5
Delete image
tototto Feb 13, 2021
ae407e1
Update DeveloperGuide.md
tototto Feb 13, 2021
6f52eee
Update DeveloperGuide.md
tototto Feb 13, 2021
624fc46
Update DeveloperGuide.md
tototto Feb 13, 2021
776906a
Update DeveloperGuide.md
tototto Feb 13, 2021
916bef1
Update DeveloperGuide.md
tototto Feb 13, 2021
282404e
Update DeveloperGuide.md
tototto Feb 13, 2021
d7af8a7
Update DeveloperGuide.md
tototto Feb 13, 2021
a948fa5
Update DeveloperGuide.md
tototto Feb 13, 2021
77d1975
Update DeveloperGuide.md
tototto Feb 13, 2021
2d62376
Update DeveloperGuide.md
tototto Feb 14, 2021
dc753fa
added Ui.png to meet submission requirmenet
tototto Feb 22, 2021
474e3c2
Update README.md
tototto Feb 23, 2021
a879088
Update README.md
tototto Feb 23, 2021
283a704
Update README.md
tototto Feb 23, 2021
9e5ecac
Update README.md
tototto Feb 23, 2021
435a4b8
Update README.md
tototto Feb 23, 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
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
# duke.Duke 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 @@ -15,7 +15,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. Click `Open or Import`.
1. Select the project directory, and click `OK`
1. If there are any further prompts, accept the defaults.
1. After the importing is complete, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()`. If the setup is correct, you should see something like the below:
1. After the importing is complete, locate the `src/main/java/duke.Duke.java` file, right-click it, and choose `Run duke.Duke.main()`. If the setup is correct, you should see something like the below:
```
Hello from
____ _
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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

import duke.command.CommandHandler;
import duke.input.InputHandler;
import duke.input.InputParser;
import duke.output.DisplayHandler;
import duke.storage.ListHandler;

Choose a reason for hiding this comment

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

Perhaps the ordering of the import statements could be reworked to align with the instantiation and dependencies below just before the while loop and inside of it as well ?


public class Duke {
public static void main(String[] args) {

// Instantiate program components
DisplayHandler displayHandler = new DisplayHandler();
InputHandler inputHandler = new InputHandler();
InputParser parser = new InputParser();
ListHandler list = new ListHandler();
CommandHandler command = new CommandHandler();

// Uses a Facade to Manage Individual Modular Components
displayHandler.ProgramOpening();

while(true) {

// Get User input
String input = inputHandler.getUserInput();
// Parse User input
String keyWord = parser.extractKeyWord(input);
String body = parser.extractKeyWordBody(input, keyWord);

// If input is not recognised Keyword
if(parser.checkIfKeyWord(keyWord) == false)
displayHandler.DisplayInvalidInput();
// If input is a recognised Keyword
else
command.checkCommandType(keyWord, body, list);

Choose a reason for hiding this comment

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

Is it good to have curly brackets for if-else statement

}
}
}
70 changes: 70 additions & 0 deletions src/main/java/duke/command/CommandHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package duke.command;//import jdk.internal.util.xml.impl.Input;

import duke.output.DisplayHandler;
import duke.storage.ListHandler;
import duke.exception.IncorrectInputException;
import duke.input.InputParser;
import duke.task.Task;

public class CommandHandler {

DisplayHandler displayHandler = new DisplayHandler();
InputParser inputParser = new InputParser();

public void checkCommandType(String KeyWord, String Body, ListHandler List) {

KEYWORD keyword = KEYWORD.valueOf(KeyWord.toUpperCase());

try{

switch(keyword){
case TODO:
String todoBody = inputParser.extractTodoBody(Body);
List.addToDo(todoBody);
Task todoTaskAdded = (Task) List.GetList().lastElement();
displayHandler.ShowTaskAdded(List.GetList().size(), todoTaskAdded);
break;

case DEADLINE:
String deadlineBody = inputParser.extractDeadlineBody(Body);
String deadlineByDate = inputParser.extractDeadlineByDay(Body);
String deadlineByTime = inputParser.extractDeadlineByTime(Body);
List.addDeadline(deadlineBody, deadlineByDate, deadlineByTime);
Task deadlineTaskAdded = (Task) List.GetList().lastElement();
displayHandler.ShowTaskAdded(List.GetList().size(), deadlineTaskAdded);
break;

case EVENT:
String eventBody = inputParser.extractEventBody(Body);
String eventDay = inputParser.extractEventAtDay(Body);;
String eventTime = inputParser.extractEventAtTime(Body);
List.addEvent(eventBody, eventDay, eventTime);
Task EventTaskAdded = (Task) List.GetList().lastElement();
displayHandler.ShowTaskAdded(List.GetList().size(), EventTaskAdded);
break;

case LIST:
displayHandler.DisplayList(List.GetList());
break;

case DONE:
Task task = List.UpdateListItem(Body);
displayHandler.DisplayChanges(task);
break;

case BYE:
displayHandler.ProgramEnding();
System.exit(0);
break;
}

} catch (Exception e){
if(e instanceof IncorrectInputException){
displayHandler.DisplayCustomException(e);
}
else {
displayHandler.DisplayInvalidInput();
}
}
}
}
11 changes: 11 additions & 0 deletions src/main/java/duke/command/KEYWORD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package duke.command;

public enum KEYWORD {

Choose a reason for hiding this comment

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

Perhaps we can use the PascalCase here for enum ?
Reference: https://se-education.org/guides/conventions/java/index.html#naming

TODO,
DEADLINE,
EVENT,
LIST,
DONE,
BYE
}

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

public class IncorrectInputException extends Exception {
public IncorrectInputException(String message){
super(message);
}
}
15 changes: 15 additions & 0 deletions src/main/java/duke/input/InputHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package duke.input;

import java.util.Scanner;

public class InputHandler {

static private Scanner fromInputStream = new Scanner(System.in);

public String getUserInput(){

String command = fromInputStream.nextLine();

return command;
}
}
146 changes: 146 additions & 0 deletions src/main/java/duke/input/InputParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package duke.input;

import duke.output.DisplayHandler;
import duke.command.KEYWORD;
import duke.exception.IncorrectInputException;

public class InputParser {

// Check if First Word is Keyword
public boolean checkIfKeyWord(String input) {

try {
KEYWORD.valueOf(input.toUpperCase());
return true;

} catch (IllegalArgumentException e) {
return false;
}
}

// Extract Keyword from Input
public String extractKeyWord(String input) {
String[] Array = input.split(" ");
return Array[0];
}

// Extract Body from Input
public String extractKeyWordBody(String input, String keyword) {
try {
return input.replaceFirst(keyword, "");

} catch(ArrayIndexOutOfBoundsException e){ // May not be used anymore
return null;
}
}

// For Todos
public String extractTodoBody(String todoInput) throws IncorrectInputException {
if(todoInput.isEmpty())
throw new IncorrectInputException(DisplayHandler.EMPTY_TODO);

return todoInput;
}

// For Deadlines
public String extractDeadlineBody(String deadlineInput) throws IncorrectInputException {
String result = "";
try{
int indx = deadlineInput.indexOf("/by");
result = deadlineInput.substring(0, indx);

} catch (Exception e){
if(result.length() < 1){
throw new IncorrectInputException(DisplayHandler.EMPTY_DEADLINE_DESC);
}
}
return result;
}

public String extractDeadlineByDay(String deadlineInput) throws IncorrectInputException{
String day = "";
try{
int indx = deadlineInput.indexOf("/by");
String by = deadlineInput.substring(indx, deadlineInput.length());
String[] array = by.split(" ");
day = array[1];
return day;

}catch (Exception e) {
if(day.length() < 1){
throw new IncorrectInputException(DisplayHandler.EMPTY_DEADLINE_DAY);
}
}

return day;
}

public String extractDeadlineByTime(String deadlineInput) throws IncorrectInputException {
String time = "";
try{
int indx = deadlineInput.indexOf("/by");
String by = deadlineInput.substring(indx);
String[] array = by.split(" ");
time = array[2];

} catch (Exception e) {
if(time.length() < 1){
throw new IncorrectInputException(DisplayHandler.EMPTY_DEADLINE_TIME);
}
}

return time;
}

// For Events
public String extractEventBody(String eventInput) throws IncorrectInputException {
String result = "";

try{
int indx = eventInput.indexOf("/at");
result = eventInput.substring(0, indx);

}catch (Exception e){
if(result.length() < 1){
throw new IncorrectInputException(DisplayHandler.EMPTY_EVENT_DESC);
}
}

return result;
}

public String extractEventAtDay(String eventInput) throws IncorrectInputException{
String day = "";

try {
int indx = eventInput.indexOf("/at");
String by = eventInput.substring(indx, eventInput.length());
String[] array = by.split(" ");
day = array[1];

}catch (Exception e) {
if(day.length() < 1){
throw new IncorrectInputException(DisplayHandler.EMPTY_EVENT_DAY);
}
}
return day;
}

public String extractEventAtTime(String eventInput) throws IncorrectInputException {
String time = "";

try{
int indx = eventInput.indexOf("/at");
String by = eventInput.substring(indx);
String[] array = by.split(" ");
time = array[2];

} catch (Exception e) {
if(time.length() < 1){
throw new IncorrectInputException(DisplayHandler.EMPTY_EVENT_TIME);
}
}

return time;
}
}
Loading