Skip to content

Commit

Permalink
Ceated Jar File
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzongxian committed Sep 13, 2022
1 parent 589e3a0 commit 452c8cb
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 30 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ repositories {
}

dependencies {

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'

String javaFxVersion = '11'

implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
Expand Down Expand Up @@ -43,7 +48,7 @@ test {
}

application {
mainClassName = "duke.Duke"
mainClassName = "duke.Launcher"
}

shadowJar {
Expand Down
2 changes: 0 additions & 2 deletions src/main/duke.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
[E][] project meeting (at: Mon 2-4pm)
[D][] return book (by: 2019-12-02 2/12/2019 1800)
3 changes: 2 additions & 1 deletion src/main/java/duke/DialogBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ public static DialogBox getDukeDialog(String text, Image img) {
db.flip();
return db;
}
}

}
33 changes: 21 additions & 12 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package duke;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.*;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;


import java.awt.*;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* This class is responsible for the bot Duke
Expand All @@ -25,7 +26,7 @@
public class Duke extends Application {

// Attributes of a Duke object
private static final String FILEDESTINATION = "./src/main/duke.txt";
private static final String FILEDESTINATION = "./duke.txt";
private Ui ui;
private Storage storage;
private TaskList taskList;
Expand All @@ -42,7 +43,7 @@ public class Duke extends Application {
/**
* The constructor for the Duke class
*/
public Duke() {
public Duke() throws IOException {
ui = new Ui();
storage = new Storage(FILEDESTINATION);
taskList = new TaskList();
Expand Down Expand Up @@ -161,6 +162,8 @@ protected String getResponse(String input) throws IOException {
String userCommand = input;
if (userCommand.equals("bye")) {
return ui.bye();
} else if (userCommand.equals("hello")) {
return ui.greet();
} else if (userCommand.equals("list")) {
return ui.showTaskList();
} else {
Expand Down Expand Up @@ -340,6 +343,12 @@ public void run() throws DukeException, IOException {
}
}

/**
* Find matching tasks from the keywords
* @param taskArrayList the list of all the tasks
* @param keywords the keywords that the user entered
* @return the string listing all the tasks that match the keywords
*/
public String findMatchingTasksFromKeywords(List<Task> taskArrayList, String keywords) {
String outputString = "";
outputString += "Here are the matching tasks in your list:\n";
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/duke/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class Launcher {
public static void main(String[] args) {
Application.launch(Main.class, args);
}
}

}
3 changes: 3 additions & 0 deletions src/main/java/duke/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class Main extends Application {

private Duke duke = new Duke();

public Main() throws IOException {
}

@Override
public void start(Stage stage) {
try {
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/duke/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package duke;

import java.awt.Color;
import java.io.IOException;

import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.VBox;

import java.awt.*;
import java.io.IOException;

/**
* Controller for MainWindow. Provides the layout for the other controls.
Expand All @@ -29,12 +34,15 @@ public class MainWindow extends AnchorPane {
private Image userImage = new Image(this.getClass().getResourceAsStream("/images/user.png"));
private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/user2.png"));

/**
* Initialise the window
*/
@FXML
public void initialize() {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());

// Generate the background colour for the Dialog
java.awt.Color awtColor = Color.cyan ;
java.awt.Color awtColor = Color.cyan;
int r = awtColor.getRed();
int g = awtColor.getGreen();
int b = awtColor.getBlue();
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package duke;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
Expand All @@ -21,8 +18,14 @@ public class Storage {
* Constructor for the Storage class
* @param fileDestination the destination filepath of the file
*/
public Storage(String fileDestination) {
public Storage(String fileDestination) throws IOException {
this.fileDestination = fileDestination;
File file = new File(fileDestination);
if (file.exists()) {
return;
}
file.getParentFile().mkdirs();
file.createNewFile();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public Ui() {
/**
* Greets the user
*/
public String greet() { return GREETING;}
public String greet() {
return GREETING;
}

/**
* Say bye to the user
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/duke/DeadlineTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package duke;

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

import java.time.LocalDate;

import org.junit.jupiter.api.Test;


public class DeadlineTest {

@Test
public void toStringTest() throws DukeException {
LocalDate by = LocalDate.parse("2019-12-02");
Deadline newDeadline = new Deadline("Deadline", by, "1800" );
Deadline newDeadline = new Deadline("Deadline", by, "1800");
assertEquals("[D][] Deadline (by: 2019-12-02 1800)", newDeadline.toString());
}

Expand All @@ -20,4 +23,4 @@ public void anotherToStringTest() throws DukeException {
assertEquals("[D][] Deadline (by: 2022-08-15 2300)", newDeadline.toString());
}

}
}

0 comments on commit 452c8cb

Please sign in to comment.