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
BOUARE Awa
FirefighterStarter
Commits
7aa7b495
Commit
7aa7b495
authored
1 year ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
minor renaming
parent
64119975
Branches
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/main/java/model/FirefighterBoard.java
+4
-4
4 additions, 4 deletions
src/main/java/model/FirefighterBoard.java
src/main/java/view/FirefighterGrid.java
+22
-13
22 additions, 13 deletions
src/main/java/view/FirefighterGrid.java
with
26 additions
and
17 deletions
src/main/java/model/FirefighterBoard.java
+
4
−
4
View file @
7aa7b495
...
@@ -58,13 +58,13 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
...
@@ -58,13 +58,13 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
}
}
public
List
<
Position
>
updateToNextGeneration
()
{
public
List
<
Position
>
updateToNextGeneration
()
{
List
<
Position
>
result
=
activ
ateFirefighters
();
List
<
Position
>
result
=
upd
ateFirefighters
();
result
.
addAll
(
activ
ateFires
());
result
.
addAll
(
upd
ateFires
());
step
++;
step
++;
return
result
;
return
result
;
}
}
private
List
<
Position
>
activ
ateFires
()
{
private
List
<
Position
>
upd
ateFires
()
{
List
<
Position
>
result
=
new
ArrayList
<>();
List
<
Position
>
result
=
new
ArrayList
<>();
if
(
step
%
2
==
0
)
{
if
(
step
%
2
==
0
)
{
List
<
Position
>
newFirePositions
=
new
ArrayList
<>();
List
<
Position
>
newFirePositions
=
new
ArrayList
<>();
...
@@ -83,7 +83,7 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
...
@@ -83,7 +83,7 @@ public class FirefighterBoard implements Board<List<ModelElement>> {
return
step
;
return
step
;
}
}
private
List
<
Position
>
activ
ateFirefighters
()
{
private
List
<
Position
>
upd
ateFirefighters
()
{
List
<
Position
>
result
=
new
ArrayList
<>();
List
<
Position
>
result
=
new
ArrayList
<>();
List
<
Position
>
firefighterNewPositions
=
new
ArrayList
<>();
List
<
Position
>
firefighterNewPositions
=
new
ArrayList
<>();
for
(
Position
firefighterPosition
:
firefighterPositions
)
{
for
(
Position
firefighterPosition
:
firefighterPositions
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/view/FirefighterGrid.java
+
22
−
13
View file @
7aa7b495
...
@@ -12,7 +12,6 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -12,7 +12,6 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
private
void
paintElementAtPosition
(
ViewElement
element
,
Position
position
)
{
private
void
paintElementAtPosition
(
ViewElement
element
,
Position
position
)
{
paintSquare
(
position
.
row
(),
position
.
column
(),
element
.
color
);
paintSquare
(
position
.
row
(),
position
.
column
(),
element
.
color
);
}
}
private
int
squareWidth
;
private
int
squareWidth
;
private
int
squareHeight
;
private
int
squareHeight
;
private
int
columnCount
;
private
int
columnCount
;
...
@@ -20,19 +19,27 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -20,19 +19,27 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
@Override
@Override
public
void
repaint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
public
void
repaint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
paint
(
positionedElements
);
paintLines
();
}
private
void
paint
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
for
(
Pair
<
Position
,
ViewElement
>
pair
:
positionedElements
){
for
(
Pair
<
Position
,
ViewElement
>
pair
:
positionedElements
){
paintElementAtPosition
(
pair
.
getValue
(),
pair
.
getKey
());
paintElementAtPosition
(
pair
.
getValue
(),
pair
.
getKey
());
}
}
paintLines
();
}
}
@Override
@Override
public
void
repaint
(
ViewElement
[][]
elements
)
{
public
void
repaint
(
ViewElement
[][]
elements
)
{
paint
(
elements
);
paintLines
();
}
private
void
paint
(
ViewElement
[][]
elements
)
{
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
for
(
int
row
=
0
;
row
<
rowCount
;
row
++){
for
(
int
row
=
0
;
row
<
rowCount
;
row
++){
paintElementAtPosition
(
elements
[
row
][
column
],
new
Position
(
row
,
column
));
paintElementAtPosition
(
elements
[
row
][
column
],
new
Position
(
row
,
column
));
}
}
paintLines
();
}
}
public
int
columnCount
()
{
public
int
columnCount
()
{
...
@@ -43,9 +50,6 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -43,9 +50,6 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
return
rowCount
;
return
rowCount
;
}
}
public
FirefighterGrid
(){
}
@Override
@Override
public
void
setDimensions
(
int
columnCount
,
int
rowCount
,
int
squareWidth
,
int
squareHeight
)
{
public
void
setDimensions
(
int
columnCount
,
int
rowCount
,
int
squareWidth
,
int
squareHeight
)
{
this
.
squareWidth
=
squareWidth
;
this
.
squareWidth
=
squareWidth
;
...
@@ -55,17 +59,22 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
...
@@ -55,17 +59,22 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
}
}
private
void
paintLines
(){
private
void
paintLines
(){
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
paintHorizontalLines
();
getGraphicsContext2D
().
strokeLine
(
0
,
column
*
squareHeight
,
getWidth
(),
column
*
squareWidth
);
paintVerticalLines
();
for
(
int
row
=
0
;
row
<
rowCount
;
row
++)
}
getGraphicsContext2D
().
strokeLine
(
row
*
squareHeight
,
0
,
row
*
squareHeight
,
getHeight
());
private
void
paintVerticalLines
()
{
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
getGraphicsContext2D
().
strokeLine
(
column
*
squareWidth
,
0
,
column
*
squareWidth
,
getHeight
());
}
private
void
paintHorizontalLines
()
{
for
(
int
row
=
0
;
row
<
rowCount
;
row
++)
getGraphicsContext2D
().
strokeLine
(
0
,
row
*
squareHeight
,
getWidth
(),
row
*
squareHeight
);
}
}
private
void
paintSquare
(
int
row
,
int
column
,
Color
color
){
private
void
paintSquare
(
int
row
,
int
column
,
Color
color
){
getGraphicsContext2D
().
setFill
(
color
);
getGraphicsContext2D
().
setFill
(
color
);
getGraphicsContext2D
().
fillRect
(
row
*
squareHeight
,
column
*
squareWidth
,
squareHeight
,
squareWidth
);
getGraphicsContext2D
().
fillRect
(
row
*
squareHeight
,
column
*
squareWidth
,
squareHeight
,
squareWidth
);
}
}
}
}
\ No newline at end of file
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