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
7af302a3
Commit
7af302a3
authored
1 year ago
by
LABOUREL Arnaud
Browse files
Options
Downloads
Patches
Plain Diff
renaming square
parent
5215c648
No related branches found
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/app/SimulatorApplication.java
+3
-3
3 additions, 3 deletions
src/main/java/app/SimulatorApplication.java
src/main/java/view/FirefighterGrid.java
+15
-15
15 additions, 15 deletions
src/main/java/view/FirefighterGrid.java
with
18 additions
and
18 deletions
src/main/java/app/SimulatorApplication.java
+
3
−
3
View file @
7af302a3
...
...
@@ -15,8 +15,8 @@ public class SimulatorApplication extends javafx.application.Application {
private
static
final
String
APP_NAME
=
"Firefighter simulator"
;
private
static
final
int
ROW_COUNT
=
20
;
private
static
final
int
COLUMN_COUNT
=
20
;
private
static
final
int
SQUARE
_WIDTH
=
50
;
private
static
final
int
SQUARE
_HEIGHT
=
50
;
private
static
final
int
BOX
_WIDTH
=
50
;
private
static
final
int
BOX
_HEIGHT
=
50
;
public
static
final
int
INITIAL_FIRE_COUNT
=
3
;
public
static
final
int
INITIAL_FIREFIGHTER_COUNT
=
6
;
...
...
@@ -43,7 +43,7 @@ public class SimulatorApplication extends javafx.application.Application {
loader
.
setLocation
(
location
);
view
=
loader
.
load
();
Controller
controller
=
loader
.
getController
();
controller
.
initialize
(
SQUARE
_WIDTH
,
SQUARE
_HEIGHT
,
COLUMN_COUNT
,
ROW_COUNT
,
controller
.
initialize
(
BOX
_WIDTH
,
BOX
_HEIGHT
,
COLUMN_COUNT
,
ROW_COUNT
,
INITIAL_FIRE_COUNT
,
INITIAL_FIREFIGHTER_COUNT
);
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/view/FirefighterGrid.java
+
15
−
15
View file @
7af302a3
...
...
@@ -10,10 +10,10 @@ import java.util.List;
public
class
FirefighterGrid
extends
Canvas
implements
Grid
<
ViewElement
>{
private
void
paintElementAtPosition
(
ViewElement
element
,
Position
position
)
{
paint
Square
(
position
.
row
(),
position
.
column
(),
element
.
color
);
paint
Box
(
position
.
row
(),
position
.
column
(),
element
.
color
);
}
private
int
square
Width
;
private
int
square
Height
;
private
int
box
Width
;
private
int
box
Height
;
private
int
columnCount
;
private
int
rowCount
;
...
...
@@ -27,7 +27,7 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
private
void
clear
(
List
<
Pair
<
Position
,
ViewElement
>>
positionedElements
)
{
for
(
Pair
<
Position
,
ViewElement
>
positionElement
:
positionedElements
)
{
Position
position
=
positionElement
.
getKey
();
clear
Square
(
position
.
row
(),
position
.
column
());
clear
Box
(
position
.
row
(),
position
.
column
());
}
}
...
...
@@ -64,13 +64,13 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
}
@Override
public
void
setDimensions
(
int
columnCount
,
int
rowCount
,
int
square
Width
,
int
square
Height
)
{
this
.
square
Width
=
square
Width
;
this
.
square
Height
=
square
Height
;
public
void
setDimensions
(
int
columnCount
,
int
rowCount
,
int
box
Width
,
int
box
Height
)
{
this
.
box
Width
=
box
Width
;
this
.
box
Height
=
box
Height
;
this
.
columnCount
=
columnCount
;
this
.
rowCount
=
rowCount
;
super
.
setWidth
(
square
Width
*
columnCount
);
super
.
setHeight
(
square
Height
*
rowCount
);
super
.
setWidth
(
box
Width
*
columnCount
);
super
.
setHeight
(
box
Height
*
rowCount
);
}
private
void
paintLines
(){
...
...
@@ -80,20 +80,20 @@ public class FirefighterGrid extends Canvas implements Grid<ViewElement>{
private
void
paintVerticalLines
()
{
for
(
int
column
=
0
;
column
<
columnCount
;
column
++)
getGraphicsContext2D
().
strokeLine
(
column
*
square
Width
,
0
,
column
*
square
Width
,
getHeight
());
getGraphicsContext2D
().
strokeLine
(
column
*
box
Width
,
0
,
column
*
box
Width
,
getHeight
());
}
private
void
paintHorizontalLines
()
{
for
(
int
row
=
0
;
row
<
rowCount
;
row
++)
getGraphicsContext2D
().
strokeLine
(
0
,
row
*
square
Height
,
getWidth
(),
row
*
square
Height
);
getGraphicsContext2D
().
strokeLine
(
0
,
row
*
box
Height
,
getWidth
(),
row
*
box
Height
);
}
private
void
paint
Square
(
int
row
,
int
column
,
Color
color
){
private
void
paint
Box
(
int
row
,
int
column
,
Color
color
){
getGraphicsContext2D
().
setFill
(
color
);
getGraphicsContext2D
().
fillRect
(
column
*
square
Width
,
row
*
square
Height
,
square
Width
,
square
Height
);
getGraphicsContext2D
().
fillRect
(
column
*
box
Width
,
row
*
box
Height
,
box
Width
,
box
Height
);
}
private
void
clear
Square
(
int
row
,
int
column
){
getGraphicsContext2D
().
clearRect
(
column
*
square
Width
,
row
*
square
Height
,
square
Width
,
square
Height
);
private
void
clear
Box
(
int
row
,
int
column
){
getGraphicsContext2D
().
clearRect
(
column
*
box
Width
,
row
*
box
Height
,
box
Width
,
box
Height
);
}
}
\ 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