Skip to content
Snippets Groups Projects
Commit 71a92a62 authored by Nimrod Abramovich's avatar Nimrod Abramovich
Browse files

Added file reading to load file button

parent 39ce81d8
No related branches found
No related tags found
No related merge requests found
No preview for this file type
11+ 1,7
2÷ 2,3
20x 4,10
6x 5,6,12,18
3- 8,9
3÷ 11,17
240x 13,14,19,20
6x 15,16
6x 21,27
7+ 22,28,29
30x 23,24
6x 25,26
9+ 30,36
8+ 31,32,33
2÷ 34,35
\ No newline at end of file
package coursework;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javafx.application.*;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
......@@ -132,8 +137,19 @@ public class Main extends Application {
topHBox.getChildren().addAll(loadGameFileButton, showMistakesButton, loadGameTextInputButton);
final String PATH = "C:\\Java Eclipse Workspace\\Programming II Coursework\\mathdokuCage.txt";
loadGameFileButton.setOnAction(e -> {
try {
BufferedReader file = new BufferedReader(new FileReader(PATH));
String line;
while ((line = file.readLine()) != null) {
System.out.println(line);
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
});
return topHBox;
......@@ -193,11 +209,11 @@ public class Main extends Application {
private void setupCages() {
new Cage(new int[] {0,6},11,"+");
new Cage(new int[] {1,2},2,"/");
new Cage(new int[] {1,2},2,"");
new Cage(new int[] {3,9},20,"x");
new Cage(new int[] {7,8},3,"-");
new Cage(new int[] {4,5,11,17},6,"x");
new Cage(new int[] {10, 16},3,"/");
new Cage(new int[] {10, 16},3,"");
new Cage(new int[] {12,13,18,19},240,"x");
new Cage(new int[] {14,15},6,"x");
new Cage(new int[] {24,25},6,"x");
......@@ -205,7 +221,7 @@ public class Main extends Application {
new Cage(new int[] {21,27,28},7,"+");
new Cage(new int[] {22,23},30,"x");
new Cage(new int[] {30,31,32},8,"+");
new Cage(new int[] {33,34},2,"/");
new Cage(new int[] {33,34},2,"");
new Cage(new int[] {29,35},9,"+");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment