diff options
author | Size43 | 2015-04-23 16:30:39 +0200 |
---|---|---|
committer | Size43 | 2015-04-23 16:30:39 +0200 |
commit | ff1f068e4a541681ab46d6fa2e1305ac72a63f91 (patch) | |
tree | f2776207e2656fe3c3ce8bbfffb87668c1eb7d3b /app/src/main/java/com/camilstaps/rushhour/BoardLoader.java | |
parent | Cleanup (diff) |
BoardLoader added
Diffstat (limited to 'app/src/main/java/com/camilstaps/rushhour/BoardLoader.java')
-rwxr-xr-x | app/src/main/java/com/camilstaps/rushhour/BoardLoader.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java b/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java new file mode 100755 index 0000000..9285306 --- /dev/null +++ b/app/src/main/java/com/camilstaps/rushhour/BoardLoader.java @@ -0,0 +1,47 @@ +package com.camilstaps.rushhour;
+
+import android.graphics.Color;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Scanner;
+
+/**
+ * Created by Jos on 23-4-2015.
+ */
+public class BoardLoader {
+ public BoardLoader()
+ {}
+
+ public Board loadBoard(InputStream file)
+ {
+ Scanner scan = new Scanner(file);
+
+ Board board = new Board();
+
+ int numCars = scan.nextInt();
+ scan.nextLine();
+
+ for(int carN = 0; carN < numCars; carN++)
+ {
+ int x1 = scan.nextInt();
+ int y1 = scan.nextInt();
+ int x2 = scan.nextInt();
+ int y2 = scan.nextInt();
+ scan.nextLine();
+
+ int r = scan.nextInt();
+ int g = scan.nextInt();
+ int b = scan.nextInt();
+
+ Car c = new Car(new Coordinate(x1, y1), new Coordinate(x2, y2), Color.rgb(r, g, b));
+ board.add(c);
+
+ if(scan.hasNext()) scan.nextLine();
+ }
+
+ return board;
+ }
+}
|