Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FirefighterStarter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
NDIAYE Ousseynou
FirefighterStarter
Commits
3eb15055
Commit
3eb15055
authored
6 months ago
by
ousseyn01
Browse files
Options
Downloads
Patches
Plain Diff
FirefighterBoard.java is DONE
parent
3b908ed8
No related branches found
No related tags found
No related merge requests found
Pipeline
#42818
passed
6 months ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/model/FirefighterBoard.java
+7
-26
7 additions, 26 deletions
src/main/java/model/FirefighterBoard.java
with
7 additions
and
26 deletions
src/main/java/model/FirefighterBoard.java
+
7
−
26
View file @
3eb15055
...
...
@@ -29,8 +29,6 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
private
final
List
<
ElementHandler
>
handlers
=
new
ArrayList
<>();
public
FirefighterBoard
(
int
columnCount
,
int
rowCount
,
int
initialFireCount
,
int
initialFirefighterCount
,
int
initialCloudCount
,
int
initialMountainCount
)
{
this
.
columnCount
=
columnCount
;
this
.
rowCount
=
rowCount
;
...
...
@@ -51,27 +49,19 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
this
.
initialFirefighterCount
=
initialFirefighterCount
;
this
.
initialCloudCount
=
initialCloudCount
;
initializeElements
();
nextGenerationUpdater
=
new
NextGenerationUpdater
(
fire
,
clouds
,
firefighters
,
mountains
,
neighbors
);
terrainElements
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
Position
position
=
randomPosition
();
terrainElements
.
add
(
new
Route
(
position
));
}
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
Position
position
=
randomPosition
();
terrainElements
.
add
(
new
Rocaille
(
position
));
}
handlers
.
add
(
new
FireHandler
(
fire
));
handlers
.
add
(
new
FirefighterHandler
(
firefighters
));
handlers
.
add
(
new
CloudHandler
(
clouds
,
neighbors
));
handlers
.
add
(
new
MountainHandler
(
mountains
));
handlers
.
add
(
new
TerrainHandler
(
terrainElements
,
Route
.
class
,
ModelElement
.
ROUTE
));
handlers
.
add
(
new
TerrainHandler
(
terrainElements
,
Rocaille
.
class
,
ModelElement
.
ROCAILLE
));
}
handlers
.
add
(
new
TerrainHandler
(
terrainElements
,
Rocaille
.
class
,
ModelElement
.
ROCAILLE
));
}
/*
Initalisation of elements
*/
public
void
initializeElements
()
{
firefighters
=
new
ArrayList
<>();
clouds
=
new
ArrayList
<>();
...
...
@@ -79,26 +69,20 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
Set
<
Position
>
firePositions
=
new
HashSet
<>();
terrainElements
=
new
ArrayList
<>();
// List<Position> initialFirefighterPositions = new ArrayList<>();
int
targetColumn
=
9
;
for
(
int
row
=
0
;
row
<
rowCount
;
row
++)
{
Position
position
=
new
Position
(
row
,
targetColumn
);
terrainElements
.
add
(
new
Route
(
position
));
}
for
(
int
index
=
0
;
index
<
initialCloudCount
;
index
++)
{
clouds
.
add
(
new
Cloud
(
randomPosition
(),
neighbors
));
}
for
(
int
index
=
0
;
index
<
initialFireCount
;
index
++)
firePositions
.
add
(
randomPosition
());
fire
=
new
Fire
(
firePositions
,
neighbors
);
for
(
int
index
=
0
;
index
<
initialFirefighterCount
;
index
++)
{
firefighters
.
add
(
new
Firefighter
(
randomPosition
()));
}
for
(
int
index
=
0
;
index
<
initialCloudCount
;
index
++)
{
clouds
.
add
(
new
Cloud
(
randomPosition
(),
neighbors
));
}
...
...
@@ -110,11 +94,9 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
private
boolean
isPositionOccupied
(
Position
position
)
{
// Vérifie si la position est occupée par une montagne
for
(
Mountain
mountain
:
mountains
)
{
if
(
mountain
.
getPosition
().
equals
(
position
))
return
true
;
}
// Vérifie les autres éléments
for
(
Firefighter
firefighter
:
firefighters
)
{
if
(
firefighter
.
getPosition
().
equals
(
position
))
return
true
;
}
...
...
@@ -128,7 +110,6 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
return
new
Position
(
randomGenerator
.
nextInt
(
rowCount
),
randomGenerator
.
nextInt
(
columnCount
));
}
@Override
public
int
rowCount
()
{
return
rowCount
;
...
...
@@ -154,8 +135,8 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
public
void
reset
()
{
initializeElements
();
nextGenerationUpdater
.
resetStep
();
}
@Override
public
List
<
ModelElement
>
getState
(
Position
position
)
{
List
<
ModelElement
>
result
=
new
ArrayList
<>();
...
...
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