Skip to content

Commit

Permalink
Merge branch 'TempPR2' of https://github.com/ShengXue97/duke into Tem…
Browse files Browse the repository at this point in the history
…pPR2
  • Loading branch information
ShengXue97 committed Mar 2, 2020
2 parents 2a10e68 + 453e67c commit f0a19ba
Show file tree
Hide file tree
Showing 24 changed files with 281 additions and 34 deletions.
21 changes: 16 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
language: java
matrix:
include:
- jdk: openjdk11

script: >-
./config/travis/run-checks.sh &&
./gradlew clean test coverage coveralls asciidoctor
deploy:
skip_cleanup: true
provider: script
script: ./config/travis/deploy_github_pages.sh
on:
branch: master

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
install:
- TERM=dumb ./gradlew assemble

script:
- TERM=dumb ./gradlew check
150 changes: 144 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,157 @@

## Features

### Feature 1
Description of feature.
### Add Todo, Deadline, and Event
Todo is a task without any date/time attached to it e.g., visit new theme park.

Deadline is a task that need to be done before a specific date/time e.g., submit report by 11/10/2019 5pm.

Event is a task that start at a specific time and ends at a specific time e.g., team project meeting on 2/10/2019 2-4pm.
## Usage

### `Keyword` - Describe action
### todo [activity]

Adds a todo task to the task list, with *[activity]* as the description

Example of usage:

`todo borrow book`

Expected outcome:

```
Got it. I've added this task:
[T][X] borrow book
Now you have 1 tasks in the list.
```

### deadline [activity] /by [year]-[month]-[day] [hour]:[minute]

Adds a deadline task to the task list, with *[activity]* as the description,
and *[year]-[month]-[day] [hour]:[minute]* as the datetime.

Example of usage:

```
deadline rush my homework again /by 2020-03-20 09:00
```

Expected outcome:

```
Got it. I've added this task:
[D][X] rush my homework again (by: 20 Mar. 2020 09:00HRS)
Now you have 2 tasks in the list.
```

### event [activity] /at [year]-[month]-[day] [hour]:[minute] to [year]-[month]-[day] [hour]:[minute]

Adds an event task to the task list, with *[activity]* as the description,
and *[year]-[month]-[day] [hour]:[minute] to [year]-[month]-[day] [hour]:[minute]* as the datetime.

Example of usage:

```
event fireworks /at 2020-12-01 09:00 to 2020-12-01 10:00
```

Expected outcome:

```
Got it. I've added this task:
[E][X] fireworks (at: 01 Dec. 2020 09:00HRS to 01 Dec. 2020 10:00HRS)
Now you have 3 tasks in the list.
```
### list

Lists the task list

Example of usage:

`list`

Expected outcome:

```
Here are the tasks in your list:
1.[T][X] borrow book
2.[D][X] rush my homework again (by: 20 Mar. 2020 09:00HRS)
3.[E][X] fireworks (at: 01 Dec. 2020 09:00HRS to 01 Dec. 2020 10:00HRS)
```

### sort [type]

Sorts the task list by *[type]*.
*[type]* can be *description* or *datetime*.

Example of usage:

`sort description`

Expected outcome:

```
Successfully sorted your tasks list according to description. Here are the tasks in your list:
1.[T][X] borrow book
2.[E][X] fireworks (at: 01 Dec. 2020 09:00HRS to 01 Dec. 2020 10:00HRS)
3.[D][X] rush my homework again (by: 20 Mar. 2020 09:00HRS)
```

### find [keyword]

Finds a list of tasks from the task list which contains *[keyword]*.

Example of usage:

`find 09:00`

Expected outcome:

```
Here are the matching tasks in your list:
1.[E][X] fireworks (at: 01 Dec. 2020 09:00HRS to 01 Dec. 2020 10:00HRS)
2.[D][X] rush my homework again (by: 20 Mar. 2020 09:00HRS)
```

### done [number]

Marks a task from the task list as done, with *[number]* as the task number, and 1 as the first task.

Example of usage:

`done 1`

Expected outcome:

```
Nice! I've marked this task as done:
[T][V] borrow book
```

### delete [number]

Removes a task from the task list, with *[number]* as the task number, and 1 as the first task.

Example of usage:

`delete 1`

Expected outcome:

```
Noted. I've removed this task:
[T][V] borrow book
Now you have 2 tasks in the list.
```

### bye

Describe action and its outcome.
Say bye to Duke and terminates the application

Example of usage:

`keyword (optional arguments)`
`bye`

Expected outcome:

`outcome`
The application closes.
Binary file added docs/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
1 change: 1 addition & 0 deletions src/main/java/duke/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ public static DialogBox getDukeDialog(String text, Image img) {
var db = new DialogBox(text, img);
db.flip();
return db;

}
}
5 changes: 5 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ public class Duke extends Application {
public void start(Stage stage) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(Duke.class.getResource("/view/MainWindow.fxml"));

AnchorPane ap = fxmlLoader.load();

Scene scene = new Scene(ap);
scene.getStylesheets().add("view/style.css");
stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/images/DaIcon.png")));
stage.setScene(scene);
stage.show();
} catch (IOException e) {


e.printStackTrace();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class MainWindow extends AnchorPane {
public void initialize() {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
dialogContainer.prefWidthProperty().bind(scrollPane.widthProperty());

UI.UIString = "";
taskList = new TaskList();
String filePath = "./data/dukeStorage.txt";
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/duke/command/Deadlines.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* Tasks that need to be done before a specific date/time e.g., submit report by 11/10/2019 5pm.
*/
public class Deadlines extends Task {
protected String datetime = "";

public Deadlines(String description, String datetime) {
super(description);
this.datetime = datetime;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/duke/command/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* 2/10/2019 2-4pm
*/
public class Events extends Task {
protected String datetime = "";

public Events(String description, String datetime) {
super(description);
this.datetime = datetime;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/command/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class Task {
protected String description;
protected boolean isDone;
protected String datetime = "";

/**
* Constructs a Task object.
Expand Down Expand Up @@ -41,4 +42,5 @@ public String fileString() {
public boolean containsString(String keyword) {
return this.toString().contains(keyword);
}

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

import java.util.Comparator;

public class TaskDatetimeComparator implements Comparator<Task> {

@Override
public int compare(Task o1, Task o2) {
System.out.println(o1.datetime);
if (o1.datetime.equals("") && o2.datetime.equals("")){
return o1.description.compareTo(o2.description);
} else if (o1.datetime.equals("")){
return -1;
} else if (o2.datetime.equals("")){
return 1;
} else if (o1.datetime.contains(" to ") && o2.datetime.contains(" to ")){
return o1.datetime.compareTo(o2.datetime);
} else if (o1.datetime.contains(" to ")){
return 1;
} else if (o2.datetime.contains(" to ")){
return -1;
} else {
return o1.datetime.compareTo(o2.datetime);
}
}

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

import java.util.Comparator;

public class TaskDescriptionComparator implements Comparator<Task> {

@Override
public int compare(Task o1, Task o2) {
return o1.description.compareTo(o2.description);
}
}
26 changes: 21 additions & 5 deletions src/main/java/duke/tool/Command.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package duke.tool;

import duke.command.Deadlines;
import duke.command.Events;
import duke.command.Task;
import duke.command.ToDos;
import duke.command.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -49,6 +46,24 @@ public String execute(TaskList taskList, UI ui) {
outputString.append(ui.print((i + 1) + "." + taskList.get(i)));
}
return outputString.toString();
case "sort":
if (!arguments.equals("description") && !arguments.equals("datetime")){
// handle exception here
outputString.append(ui.printError("=( OOPS!!! Enter 'sort description' or 'sort datetime'."));
} else if (arguments.equals("description")) {
taskList.sort(new TaskDescriptionComparator());
outputString.append(ui.print("Successfully sorted your tasks list according to description. Here are the tasks in your list:"));
for (int i = 0; i < taskList.size(); i++) {
outputString.append(ui.print((i + 1) + "." + taskList.get(i)));
}
} else {
taskList.sort(new TaskDatetimeComparator());
outputString.append(ui.print("Successfully sorted your tasks list according to datetime. Here are the tasks in your list:"));
for (int i = 0; i < taskList.size(); i++) {
outputString.append(ui.print((i + 1) + "." + taskList.get(i)));
}
}
return outputString.toString();
case "find":
outputString.append(ui.print("Here are the matching tasks in your list:"));
int count = 0;
Expand Down Expand Up @@ -103,7 +118,8 @@ public String execute(TaskList taskList, UI ui) {
}
return outputString.toString();
case "help":
outputString.append(ui.print("List of available commands: todo, event, deadline, list, find, done, delete, bye"));
outputString.append(ui.print("List of available commands: todo, event, deadline, list, sort, find, done, delete, bye\n\n" +
"Detailed user guide is at: https://shengxue97.github.io/duke/"));
return outputString.toString();
case "todo":
if (arguments.equals("todo")){
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/duke/tool/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public Command parse(String input) {
return new Command("bye");
} else if (input.equals("list")) {
return new Command("list");
} else if (input.split(" ")[0].equals("sort")) {
return new Command("sort", input.replaceFirst("sort ", ""));
} else if (input.split(" ")[0].equals("find")) {
return new Command("find", input.replaceFirst("find ", ""));
} else if (input.split(" ")[0].equals("done")) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/duke/tool/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import duke.command.Task;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
Expand Down Expand Up @@ -35,6 +37,10 @@ public void clear() {
this.toDo.clear();
}

public void sort(Comparator<Task> comparator){
this.toDo.sort(comparator);
}

public List<Task> getToDo() {
return this.toDo;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/tool/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public String printWelcomeMessage() {
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
return "Hello! I'm Snow\nWhat can I do for you?\n" + logo + "\n";
return "Hello! I'm Snow\nWhat can I do for you?\n" + "\n";
}


Expand Down
Binary file added src/main/resources/images/mountains_snow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/snowBG.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<fx:root fx:id="myBox" alignment="TOP_RIGHT" fillHeight="false" maxHeight="Infinity" maxWidth="Infinity" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" maxHeight="Infinity" maxWidth="Infinity" text="label" textOverrun="CENTER_WORD_ELLIPSIS" wrapText="true" />
<Label fx:id="dialog" style=" -fx-padding: 12 12 12 12; -fx-background-color: grey; -fx-background-radius: 50px; -fx-border-radius: 50px; -fx-border-width: 1px; -fx-border-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.8), 10, 0, 0, 0);" text="Label" wrapText="true" />
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true" />
</children>
<padding>
Expand Down
Loading

0 comments on commit f0a19ba

Please sign in to comment.