Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Prog2Aix-tp3
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MULLER Etienne
Prog2Aix-tp3
Commits
ad595afa
Commit
ad595afa
authored
Oct 13, 2020
by
etienne
Browse files
Options
Downloads
Patches
Plain Diff
bug de répartition des couleur corrigé
parent
d75d0b87
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cell.java
+4
-2
4 additions, 2 deletions
Cell.java
GameOfLifeGUI.java
+27
-30
27 additions, 30 deletions
GameOfLifeGUI.java
Grid.java
+4
-4
4 additions, 4 deletions
Grid.java
with
35 additions
and
36 deletions
Cell.java
+
4
−
2
View file @
ad595afa
import
java.util.Random
;
/**
/**
* {@link Cell} instances represent the cells of <i>The Game of Life</i>.
* {@link Cell} instances represent the cells of <i>The Game of Life</i>.
*/
*/
...
@@ -9,7 +11,7 @@ public class Cell {
...
@@ -9,7 +11,7 @@ public class Cell {
public
Cell
(){
public
Cell
(){
this
.
isAlive
=
false
;
this
.
isAlive
=
false
;
this
.
isRed
=
false
;
this
.
isRed
=
new
Random
().
nextBoolean
()
;
}
}
...
@@ -18,7 +20,7 @@ public class Cell {
...
@@ -18,7 +20,7 @@ public class Cell {
}
}
public
boolean
isRed
(){
public
boolean
isRed
(){
return
isRed
;
return
this
.
isRed
;
}
}
/**
/**
* Determines whether this {@link Cell} is alive or not.
* Determines whether this {@link Cell} is alive or not.
...
...
This diff is collapsed.
Click to expand it.
GameOfLifeGUI.java
+
27
−
30
View file @
ad595afa
...
@@ -25,8 +25,7 @@ public class GameOfLifeGUI extends JFrame {
...
@@ -25,8 +25,7 @@ public class GameOfLifeGUI extends JFrame {
labelGrid
[
x
][
y
].
setForeground
(
Color
.
red
);
labelGrid
[
x
][
y
].
setForeground
(
Color
.
red
);
//if (g.getCell(x,y).isRed()) labelGrid[x][y].setForeground(Color.red);
//if (g.getCell(x,y).isRed()) labelGrid[x][y].setForeground(Color.red);
//else labelGrid[x][y].setForeground(Color.BLUE);
//else labelGrid[x][y].setForeground(Color.BLUE);
}
}
else
else
labelGrid
[
x
][
y
].
setForeground
(
Color
.
white
);
labelGrid
[
x
][
y
].
setForeground
(
Color
.
white
);
gridPanel
.
add
(
labelGrid
[
x
][
y
]);
gridPanel
.
add
(
labelGrid
[
x
][
y
]);
}
}
...
@@ -45,9 +44,7 @@ public class GameOfLifeGUI extends JFrame {
...
@@ -45,9 +44,7 @@ public class GameOfLifeGUI extends JFrame {
if
(
g
.
getCell
(
x
,
y
).
isAlive
())
{
if
(
g
.
getCell
(
x
,
y
).
isAlive
())
{
if
(
g
.
getCell
(
x
,
y
).
isRed
())
label
.
setForeground
(
Color
.
red
);
if
(
g
.
getCell
(
x
,
y
).
isRed
())
label
.
setForeground
(
Color
.
red
);
else
label
.
setForeground
(
Color
.
BLUE
);
else
label
.
setForeground
(
Color
.
BLUE
);
}
}
else
else
label
.
setForeground
(
Color
.
white
);
label
.
setForeground
(
Color
.
white
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Grid.java
+
4
−
4
View file @
ad595afa
...
@@ -202,8 +202,7 @@ public class Grid implements Iterable<Cell> {
...
@@ -202,8 +202,7 @@ public class Grid implements Iterable<Cell> {
private
void
goToNextColor
(
boolean
[][]
nextColor
)
{
private
void
goToNextColor
(
boolean
[][]
nextColor
)
{
for
(
int
row
=
0
;
row
<
this
.
numberOfRows
;
row
++){
for
(
int
row
=
0
;
row
<
this
.
numberOfRows
;
row
++){
for
(
int
col
=
0
;
col
<
this
.
numberOfColumns
;
col
++){
for
(
int
col
=
0
;
col
<
this
.
numberOfColumns
;
col
++){
if
(
nextColor
[
row
][
col
])
this
.
cells
[
row
][
col
].
setColor
(
true
);
this
.
cells
[
row
][
col
].
setColor
(
nextColor
[
row
][
col
]);
else
this
.
cells
[
row
][
col
].
setColor
(
false
);
}
}
}
}
...
@@ -230,8 +229,9 @@ public class Grid implements Iterable<Cell> {
...
@@ -230,8 +229,9 @@ public class Grid implements Iterable<Cell> {
void
randomGeneration
(
Random
random
)
{
void
randomGeneration
(
Random
random
)
{
for
(
int
row
=
0
;
row
<
this
.
numberOfRows
;
row
++){
for
(
int
row
=
0
;
row
<
this
.
numberOfRows
;
row
++){
for
(
int
col
=
0
;
col
<
this
.
numberOfColumns
;
col
++)
{
for
(
int
col
=
0
;
col
<
this
.
numberOfColumns
;
col
++)
{
if
(
random
.
nextBoolean
()){
int
a
=
random
.
nextInt
(
100
);
this
.
cells
[
row
][
col
].
setColor
(
random
.
nextBoolean
());
if
(
a
<=
50
){
this
.
cells
[
row
][
col
].
setColor
(
a
<
25
);
this
.
cells
[
row
][
col
].
setAlive
();
this
.
cells
[
row
][
col
].
setAlive
();
}
}
...
...
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