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

[Shui Jie] ip #493

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f3eaef6
level0
Aug 28, 2021
3ecefd8
level-1
Aug 28, 2021
26bfdad
Level 2. Add, List
Aug 28, 2021
6d29c98
Level 3. Mark as Done
Aug 28, 2021
235bf49
Level 4. ToDos, Events, Deadlines
Aug 28, 2021
ad4240f
A-Inheritance
Aug 28, 2021
6394894
A-TextUiTesting
Aug 28, 2021
bcc3b3a
Level 5. Handle Errors and A-Exceptions
Aug 28, 2021
df7a3c2
Level 6. Delete
Aug 28, 2021
af273dc
shui jie test
Aug 29, 2021
a5841b5
Revert "shui jie test"
Aug 29, 2021
0d4c6ad
Level 7. Save
Aug 30, 2021
4145601
Level 8. Dates and Times
Aug 30, 2021
a5408a7
Duke A-MoreOOP: Use More OOP
Aug 31, 2021
8a90b85
Duke A-Packages: Organize into Packages
Aug 31, 2021
656aa1e
addition to A-Package
Sep 1, 2021
71d28f8
Duke A-JUnit: Add JUnit Tests
Sep 1, 2021
e4acacb
Duke A-Jar: Create a JAR File
Sep 1, 2021
7bf0d3b
Level 9. Find
Sep 1, 2021
661d574
Duke A-Gradle: Use Gradle
Sep 4, 2021
83dbf07
Duke Level-10: GUI
Sep 5, 2021
c95f4c6
new changes to level 10
Sep 5, 2021
8e28087
gradle issue
Sep 5, 2021
9e8f13c
Revert "gradle issue"
Sep 5, 2021
82a9b74
gradle issue
Sep 5, 2021
0f66bcb
jar message
Sep 8, 2021
cb4d7a5
Created two assertions
Sep 9, 2021
4d106ab
extension check duplicate
Sep 12, 2021
5670173
C-DetectDuplicates
Sep 12, 2021
d255b4d
Improve code quality
Sep 12, 2021
53ad6cb
Improve code quality
Sep 12, 2021
01d4f8e
try to merge
Sep 12, 2021
7a19a12
Merge branch 'master' into branch-A-CodeQuality
sj1999-BIT Sep 12, 2021
8a6f0cb
Merge pull request #4 from sj1999-BIT/branch-A-CodeQuality
sj1999-BIT Sep 12, 2021
0f21f57
Improve the GUI and resolved bugs
Sep 13, 2021
5df14b1
Merge commit '4d106abb4af3ac8469ad2384c142b5ab998ebdef'
Sep 14, 2021
ebe6dc6
Set theme jekyll-theme-minimal
sj1999-BIT Sep 14, 2021
a4cafdc
Create index.md
sj1999-BIT Sep 14, 2021
8871c55
Merge branch 'master' of https://github.com/sj1999-BIT/ip
Sep 14, 2021
27efbf3
Add Docs file
Sep 14, 2021
f5c364c
Create .gitignore
Sep 14, 2021
6c1a898
stepping up user guide
Sep 14, 2021
3b7d30e
remove lock files
Sep 14, 2021
fc1578b
Update README.md
Sep 14, 2021
9a972d1
Update README.md
Sep 14, 2021
3a52ad2
Update README.md
Sep 14, 2021
21223e6
create a new jar file
Sep 15, 2021
a676875
Update README.md
sj1999-BIT Sep 18, 2021
84bc192
Update README.md
sj1999-BIT Sep 20, 2021
90277b1
Update index.md
sj1999-BIT Sep 21, 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
2 changes: 2 additions & 0 deletions Duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Todo Read
Deadline s /by Mon
Binary file added out/artifacts/Duke_java_jar/Duke.java.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions src/main/java/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/main/java/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/main/java/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/main/java/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions src/main/java/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/main/java/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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


import java.util.Scanner;
import Storage.*;
import Task.TaskList;
import Task.Task;
import Task.DeadlineException;
import Task.TodoException;
import Task.EventsException;

public class Duke {
private final Ui userInterface = new Ui();

public static void main(String[] args) {
Duke user = new Duke();
boolean end = true;
user.userInterface.greet();
user.userInterface.getDataInputList();
while (end) {
end = user.userInterface.echo();
System.out.println("__________________________________");
}
}
}


//deals with interactions with the user
class Ui {
private final Storage store = new Storage();
private TaskList taskList = new TaskList();
/**
* Generate the initiate message.
*/
public void greet() {
System.out.println("__________________________________");
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println(logo);
System.out.println("Hello! I'm Duke\n");
System.out.println("What can I do for you?");
System.out.println("__________________________________");
}

/**
* generate the end message.
*/
public void bye() {
System.out.println("Bye. Hope to see you again soon!");
store.saveListInFile("src/main/java/Duke/Duke.txt", taskList);
}
/**
* The original method to simply generate an echo message.
* Now only meant to decide if the user has decided to end
* the program.
* @return boolean
*/
public boolean echo() {
Scanner user = new Scanner(System.in);
while(user.hasNextLine()) {
String input = user.nextLine();
return choiceOfAction(input);
}
return false;
}

/**
* To decide base on the input what is the next action.
* The decision on whether to show list, set existing task to
* done, or to create and record new task.
* @param input by the user
* @return boolean
*/
public boolean choiceOfAction(String input) {
if (input.equals("bye")) {
bye();
return false;
} else if (input.equals("list")) {
taskList.showList();
return true;
} else {
String[] newInput = input.split(" ");
String instruction = newInput[0];
if (instruction.equals("done")) {
doneAction(newInput);
} else if (instruction.equals("delete")) {
deleteAction(newInput);
}else if (instruction.equals("find")) {
findAction(newInput);
} else {
try {
Task newTask = store.createTask(input);
taskList.addTask(newTask);
} catch (TodoException tx) {
System.out.println(tx.getLocalizedMessage());
} catch (DeadlineException dx) {
System.out.println(dx.getLocalizedMessage());
} catch (EventsException ex) {
System.out.println(ex.getLocalizedMessage());
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
}
return true;
}
}

/**
* Encapsulation up the class structure.
*/
public void getDataInputList() {
store.getDataInputList(this.taskList);
}

/**
* Function performs task when Done instruction is provided.
* @param newInput is a String Array containing the Done and index of the Task.
*/
private void doneAction(String[] newInput) {
if (newInput.length < 2) {
System.out.println("Please input the index of the Task to be done!");
} else {
int index = Integer.parseInt(newInput[1]);
if (index <= taskList.getTaskList().size() && index > 0) {
taskList.getTaskList().get(index - 1).done();
System.out.println("Nice! I've marked this task as done: ");
System.out.println(" " + this.taskList.getTaskList().get(index - 1));
} else {
System.out.println("invalid index");
}
}
}

/**
* Function perform the action of deleting a task when requested. It also catches
* the Exception throw.
* @param newInput is the String Array containing the index of the Task.
*/
private void deleteAction(String[] newInput) {
try {
taskList.deleteTask(newInput);
}catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
}

/**
* Action find keywords in main TaskList the fits the request.
* @param newInput is a String Array that contains the keyword needed for the search.
* @return TaskList Object containing the searched Tasks.
*/
private void findAction(String[] newInput) {
System.out.println("Here are the matching tasks in your list:");
if (newInput.length >= 2) {
String keyword = newInput[1];
//TaskList tempList = new TaskList();
for (Task curTask : this.taskList.getTaskList()) {
for (String information : curTask.getFinalAction().split(" ")) {
if (information.equals(keyword)) {
//tempList.addTaskWithoutMessage(curTask);
System.out.println(curTask);
}
}
}
//tempList.showList();
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/Duke/Duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Todo r
Deadline r /by 12/12/2019
Events rt /at 12/12/2019 1800
Loading