Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RushPascal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bariatti Francesco
RushPascal
Commits
c6e46712
Commit
c6e46712
authored
8 years ago
by
Carry Morgane
Browse files
Options
Downloads
Patches
Plain Diff
Board : constructeur par fichier ; Car : ajout de static pour l'Orientation
parent
aa383fad
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/model/Board.java
+62
-9
62 additions, 9 deletions
src/model/Board.java
src/model/Car.java
+1
-1
1 addition, 1 deletion
src/model/Car.java
with
63 additions
and
10 deletions
src/model/Board.java
+
62
−
9
View file @
c6e46712
package
model
;
import
java.io.BufferedReader
;
import
java.io.FileReader
;
import
java.io.IOException
;
public
class
Board
{
private
int
[][]
board
;
private
Car
[]
cars
;
private
Position
exit
;
public
Board
(
int
size
,
int
nbcars
){
initTab
(
size
);
cars
=
new
Car
[
nbcars
];
}
private
void
initTab
(
int
size
){
board
=
new
int
[
size
][
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++){
for
(
int
j
=
0
;
j
<
size
;
j
++){
board
[
i
][
j
]
=
-
1
;
}
}
}
//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
public
Board
(
String
filelevel
)
throws
IOException
{
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
filelevel
)
);
cars
=
new
Car
[
nbcars
];
int
size
=
Integer
.
valueOf
(
br
.
readLine
());
initTab
(
size
);
String
[]
line2
=
br
.
readLine
().
split
(
" "
);
exit
=
new
Position
(
Integer
.
valueOf
(
line2
[
0
]),
Integer
.
valueOf
(
line2
[
1
]));
int
car_number
=
Integer
.
valueOf
(
br
.
readLine
());
cars
=
new
Car
[
car_number
];
String
l
=
br
.
readLine
();
int
i
=
0
;
while
(
l
!=
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
;
}
cars
[
i
]
=
new
Car
(
i
,
pos1
,
pos2
,
or
);
l
=
br
.
readLine
();
i
++;
}
}
public
boolean
isSolved
(){
return
board
[
exit
.
getX
()][
exit
.
getY
()]
==
0
;
}
//getAllPossibleMoves();
public
int
getSize
()
{
return
board
.
length
;
public
int
getSize
()
{
return
board
.
length
;
}
public
int
getCarsNumber
()
{
return
cars
.
length
;
}
}
This diff is collapsed.
Click to expand it.
src/model/Car.java
+
1
−
1
View file @
c6e46712
...
...
@@ -215,7 +215,7 @@ public class Car
return
number
;
}
public
enum
Orientation
public
static
enum
Orientation
{
HORIZONTAL
,
VERTICAL
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment