Skip to content

Commit

Permalink
Add a user guide and product screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaxinnns committed Sep 14, 2024
1 parent 0d6064c commit 97b7617
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 29 deletions.
10 changes: 4 additions & 6 deletions data/reo.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
T | 1 | sajbds
T | 0 | shbf
E | 0 | Tutorial 3 | 1pm | 3pm
T | 0 | lab 1
T | 0 | lab 2
T | 0 | lab 3
E | 0 | Training | 9pm | 11pm
T | 0 | Lab 5
D | 1 | proposal | Sep 19 2024
D | 1 | proposal | Sep 29 2024
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.
10 changes: 8 additions & 2 deletions src/main/java/reo/storage/TaskStorage.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package reo.storage;

import reo.tasks.Todo;
import reo.tasks.Deadline;
import reo.tasks.Event;
import reo.tasks.Task;
import reo.tasks.Todo;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -12,6 +12,8 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.Stream;
Expand Down Expand Up @@ -79,7 +81,11 @@ public ArrayList<Task> readFile() {
case "D":
boolean isDoneD = convertIntToBool(Integer.parseInt(split[1].trim()));
String nameD = split[2].trim();
String deadline = split[3].trim();
String dateString = split[3].trim();
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("MMM dd yyyy");
LocalDate date = LocalDate.parse(dateString, inputFormatter);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String deadline = date.format(outputFormatter);
tasks.add(new Deadline(nameD, isDoneD, deadline));
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reo/tasks/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public String toString() {
* @return The string representation of the deadline to be written to memory.
*/
public String toFileString() {
return "T | " + super.toFileString() + " | " + dateToString();
return "D | " + super.toFileString() + " | " + dateToString();
}
}
2 changes: 0 additions & 2 deletions src/main/java/reo/tasks/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void deleteTasks(ArrayList<Integer> indexes) {
* @param taskNumber The task to be marked as done.
*/
public void markTask(int taskNumber) {
assert taskNumber >= 0 && taskNumber < tasks.size() : "Invalid task number for marking";
Task toMark = tasks.get(taskNumber);
toMark.mark();
}
Expand All @@ -40,7 +39,6 @@ public void markTask(int taskNumber) {
* @param taskNumber The task to be marked as undone.
*/
public void unmarkTask(int taskNumber) {
assert taskNumber >= 0 && taskNumber < tasks.size() : "Invalid task number for unmarking";
Task toUnmark = tasks.get(taskNumber);
toUnmark.unmark();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reo/tasks/TaskParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ public String[] parseEvent(String input) {
public String handleEvent() {
final String EVENT_CONFIRMATION = "I've added this event:\n";
final String EVENT_ERROR = "Please enter a valid task name and to & from dates.\n";
final String TASKS_LEFT_CONFIRMATION = "Now, you have " + tasks.getSize() + " task(s) in your list.\n";
try {
String name = parseEvent(input)[0];
String from = parseEvent(input)[1];
Expand All @@ -224,6 +223,7 @@ public String handleEvent() {
Event eventToPush = new Event(name, false, to, from);
tasks.addEvent(eventToPush);
storage.writeFile(eventToPush);
final String TASKS_LEFT_CONFIRMATION = "Now, you have " + tasks.getSize() + " task(s) in your list.\n";
return EVENT_CONFIRMATION + eventToPush.toString() + "\n"
+ TASKS_LEFT_CONFIRMATION;
} catch (ArrayIndexOutOfBoundsException e) {
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/reo/tasks/TaskParserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package reo.tasks;

import org.junit.jupiter.api.Test;
import reo.storage.TaskStorage;

import java.util.ArrayList;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TaskParserTest {
@Test
public void parseTodoCommand_oneWord() {
ArrayList<Task> tasks = new ArrayList<>();
TaskList taskList = new TaskList(tasks);
TaskStorage storage = new TaskStorage("./data/reo.txt");
TaskParser parser = new TaskParser("todo Lab", taskList, storage);
String response = parser.parse();

String expected = "I've added this todo:\n" +
" [T] [ ] Lab\n";
assertEquals(response, expected);
}

@Test
public void parseTodoCommand_manyWords() {
ArrayList<Task> tasks = new ArrayList<>();
tasks.add(new Todo("Test Task 1", false));
tasks.add(new Todo("Test Task 2", true));
tasks.add(new Deadline("Test Deadline 1", false, "2024-09-14"));

TaskList taskList = new TaskList(tasks);
TaskStorage storage = new TaskStorage("./data/reo.txt");
TaskParser parser = new TaskParser("todo Lab 1, 2, 3, 4", taskList, storage);

String response = parser.parse();
String expected = "I've added this todo:\n" +
" [T] [ ] Lab 1, 2, 3, 4\n";
assertEquals(response, expected);
}

@Test
public void parseTodoCommand_invalid() {
ArrayList<Task> tasks = new ArrayList<>();
tasks.add(new Todo("Test Task 1", false));
tasks.add(new Todo("Test Task 2", true));
tasks.add(new Deadline("Test Deadline 1", false, "2024-09-14"));

TaskList taskList = new TaskList(tasks);
TaskStorage storage = new TaskStorage("./data/reo.txt");
TaskParser parser = new TaskParser("todo", taskList, storage);

String response = parser.parse();
String expected = "Please enter a valid task name.\n";

assertEquals(response, expected);
}
}
4 changes: 2 additions & 2 deletions src/main/java/reo/ui/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ private void flip() {

public static DialogBox getUserDialog(String text, Image img) {
var db = new DialogBox(text, img);
db.dialog.setStyle("-fx-background-color: lightblue;");
db.dialog.setStyle("-fx-background-color: lightgray;");
return db;
}

public static DialogBox getReoDialog(String text, Image img) {
var db = new DialogBox(text, img);
db.flip();
db.dialog.setStyle("-fx-background-color: lightgray;");
db.dialog.setStyle("-fx-background-color: #CBC3E3;");
return db;
}
}
1 change: 0 additions & 1 deletion src/main/java/reo/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public void start(Stage stage) {
tasklist = new TaskList(new ArrayList<Task>());
}

// TODO: ADD FILE READING
ContactStorage contactStorage = new ContactStorage("./data/contacts.txt");
ContactList contactList;

Expand Down
Binary file modified src/main/resources/images/DaDuke.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 modified src/main/resources/images/DaUser.png
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 @@ -27,7 +27,7 @@
<ImageView fx:id="displayPicture" fitHeight="60.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" />
</children>
<padding>
<Insets bottom="15.0" left="5.0" right="5.0" top="15.0" />
<Insets bottom="10.0" left="5.0" right="5.0" top="10.0" />
</padding>
</fx:root>

32 changes: 19 additions & 13 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,36 @@
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="reo.ui.MainWindow">
<children>
<!-- User Input TextField -->
<TextField fx:id="userInput"
layoutY="558.0"
onAction="#handleUserInput"
prefHeight="41.0"
prefWidth="324.0"
AnchorPane.bottomAnchor="1.0" />
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="80.0"
AnchorPane.bottomAnchor="0.0" />

<!-- Send Button -->
<Button fx:id="sendButton"
layoutX="324.0"
layoutY="558.0"
mnemonicParsing="false"
onAction="#handleUserInput"
prefHeight="41.0"
prefWidth="76.0"
text="Send" />
text="Send"
AnchorPane.rightAnchor="0.0"
AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="320.0" />

<!-- ScrollPane to hold dialog -->
<ScrollPane fx:id="scrollPane"
hbarPolicy="NEVER"
hvalue="1.0"
prefHeight="557.0"
prefWidth="400.0"
vvalue="1.0">
vbarPolicy="AS_NEEDED"
AnchorPane.topAnchor="0.0"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
AnchorPane.bottomAnchor="41.0">
<content>
<!-- VBox for dialog content -->
<VBox fx:id="dialogContainer"
prefHeight="552.0"
prefWidth="388.0" />
prefWidth="400.0"/>
</content>
</ScrollPane>
</children>
Expand Down

0 comments on commit 97b7617

Please sign in to comment.