Skip to content
Snippets Groups Projects
Commit 03e4e948 authored by Bariatti Francesco's avatar Bariatti Francesco
Browse files

Added javadoc in Board class constructor and small changes in it

parent c74cdb1e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,6 @@
# IntelliJ
.idea/
RushPascal.iml
out/
# Project
bin
......@@ -24,11 +24,18 @@ public class Board {
}
}
}
//filelevel : ligne 1 : taille
//ligne 2 : x et y de la sortie
//ligne 3 : nombre de voitures
//après : les voitures : xfront yfront xback yback
/**
* Load the board from a file.
* Structure of the file:
* 1st line: size of the board (the board is a square)
* 2nd line: x positition and y position of the goal
* 3rd line: number of cars in the level
* Following lines: every line defines a car: values of xFront<SPACE>yFront<SPACE>xBack<SPACE>yBack
*
* @param filelevel The name of the file
* @throws IOException On file reading errors
*/
public Board(String filelevel) throws IOException{
BufferedReader br = new BufferedReader( new FileReader(filelevel) );
......@@ -44,24 +51,14 @@ public class Board {
cars = new Car[car_number];
String l = br.readLine();
int i = 0;
while(l != null){
String l;
while((l = br.readLine()) != null){
String[] splitl = l.split(" ");
Position pos1 = new Position(Integer.valueOf(splitl[0]), Integer.valueOf(splitl[1]));
Position pos2 = new Position(Integer.valueOf(splitl[2]), Integer.valueOf(splitl[3]));
Car.Orientation or ;
if(splitl[4].equals("HORIZONTAL")){
or = Car.Orientation.HORIZONTAL;
} else {
or = Car.Orientation.VERTICAL;
}
Car car = new Car(i, pos1, pos2, or);
Car car = new Car(i, pos1, pos2, Car.Orientation.valueOf(splitl[4]));
cars[i] = car;
if(car.getOrientation() == Car.Orientation.HORIZONTAL)
......@@ -70,12 +67,7 @@ public class Board {
if(car.getOrientation() == Car.Orientation.VERTICAL)
for(int y = car.getBack().getY(); y <= car.getFront().getY(); y++)
board[car.getFront().getX()][y] = car.getNumber();
l = br.readLine();
i++;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment