Skip to content

Commit

Permalink
Fix storage path and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
colintkn committed Feb 5, 2021
1 parent 610d919 commit 736b845
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ checkstyle {
}

shadowJar {
mainClassName = 'Percy'
mainClassName = 'Launcher'
}

repositories {
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/percy/storage/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@
*/
public class Storage {
private static final String DELIMITER = " \\| ";
private final String filePath = "./data/percy.txt";

private File file;
private final String filePath = "data/percy.txt";

/**
* Constructs storage.
*/
public Storage() {
this.file = new File(filePath);
/*
// assert file != null;
if (!this.file.exists()) { // If file does not exist, folder does not exist
file.getParentFile().mkdir(); // Creates data folder
file.createNewFile(); // throws IOException create a file in abstract directory
assert file != null;
try {
if (!this.file.exists()) { // If file does not exist, folder does not exist
file.getParentFile().mkdir(); // Creates data folder
file.createNewFile(); // throws IOException create a file in abstract directory
}
}
catch (IOException ex) {
System.err.println(ex);
}
*/
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/storage/percy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
T | 1 | return book
T | 1 | read book
D | 0 | feed dog | 2015-08-31 1500
E | 0 | concert | 2015-04-21 1200
T | 1 | feed percy
2 changes: 1 addition & 1 deletion src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>

<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1">
<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml">
<children>
<Label fx:id="dialog" maxHeight="1.7976931348623157E308" minHeight="-Infinity" style="-fx-shape: &quot;M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z&quot;&quot;M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z&quot;; -fx-padding: 30; -fx-background-color: rgba(53,89,119,0.4)rgba(53,89,119,0.4); -fx-background-insets: 5;" text="Label" wrapText="true" HBox.hgrow="ALWAYS" />
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="MainWindow">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="MainWindow">
<children>
<TextField fx:id="userInput" layoutY="558.0" onAction="#handleUserInput" prefHeight="41.0" prefWidth="324.0" promptText="Say something to Percy! " AnchorPane.bottomAnchor="1.0" />
<Button fx:id="sendButton" layoutX="324.0" layoutY="558.0" mnemonicParsing="false" onAction="#handleUserInput" prefHeight="41.0" prefWidth="76.0" text="Send" />
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/view/test.fxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>


<?import javafx.scene.chart.AreaChart?>
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.NumberAxis?>
Expand Down

0 comments on commit 736b845

Please sign in to comment.