Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Prog2Aix-tp3 MOHAMED
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
HAMADACHE Mohamed
Prog2Aix-tp3 MOHAMED
Commits
04a2093b
Commit
04a2093b
authored
4 years ago
by
HAMADACHE Mohamed
Browse files
Options
Downloads
Patches
Plain Diff
ok
parent
adb13dc8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cell.java
+40
-22
40 additions, 22 deletions
Cell.java
with
40 additions
and
22 deletions
Cell.java
+
40
−
22
View file @
04a2093b
...
@@ -4,11 +4,13 @@
...
@@ -4,11 +4,13 @@
public
class
Cell
{
public
class
Cell
{
private
boolean
isAlive
;
private
boolean
isAlive
;
private
boolean
isBlue
;
public
Cell
(){
public
Cell
()
{
this
.
isAlive
=
false
;
this
.
isAlive
=
false
;
this
.
isBlue
=
false
;
}
}
/**
/**
* Determines whether this {@link Cell} is alive or not.
* Determines whether this {@link Cell} is alive or not.
*
*
...
@@ -19,6 +21,10 @@ public class Cell {
...
@@ -19,6 +21,10 @@ public class Cell {
return
this
.
isAlive
;
return
this
.
isAlive
;
}
}
public
boolean
isBlue
()
{
return
this
.
isBlue
;
}
/**
/**
* Determines whether this {@link Cell} is dead or not.
* Determines whether this {@link Cell} is dead or not.
*
*
...
@@ -29,6 +35,10 @@ public class Cell {
...
@@ -29,6 +35,10 @@ public class Cell {
return
!
this
.
isAlive
;
return
!
this
.
isAlive
;
}
}
public
boolean
isRed
()
{
return
!
this
.
isBlue
;
}
/**
/**
* Sets the state of this {@link Cell} to alive.
* Sets the state of this {@link Cell} to alive.
*
*
...
@@ -36,9 +46,14 @@ public class Cell {
...
@@ -36,9 +46,14 @@ public class Cell {
*/
*/
public
void
setAlive
()
{
public
void
setAlive
()
{
this
.
isAlive
=
true
;
this
.
isAlive
=
true
;
}
}
public
void
setBlue
()
{
this
.
isBlue
=
true
;
}
/**
/**
* Sets the state of this {@link Cell} to dead.
* Sets the state of this {@link Cell} to dead.
*
*
...
@@ -46,7 +61,11 @@ public class Cell {
...
@@ -46,7 +61,11 @@ public class Cell {
*/
*/
public
void
setDead
()
{
public
void
setDead
()
{
this
.
isAlive
=
false
;
this
.
isAlive
=
false
;
}
public
void
setRed
()
{
this
.
isBlue
=
false
;
}
}
...
@@ -55,24 +74,23 @@ public class Cell {
...
@@ -55,24 +74,23 @@ public class Cell {
*/
*/
public
void
toggleState
()
{
public
void
toggleState
()
{
if
(
this
.
isAlive
)
if
(
this
.
isAlive
)
this
.
isAlive
=
false
;
this
.
isAlive
=
false
;
else
else
this
.
isAlive
=
true
;
this
.
isAlive
=
true
;
}
}
public
boolean
isAliveInNextState
(
int
numberOfAliveNeighbours
)
{
public
boolean
isAliveInNextState
(
int
numberOfAliveNeighbours
)
{
if
(
isAlive
()){
if
(
isAlive
())
{
if
(
numberOfAliveNeighbours
==
2
||
numberOfAliveNeighbours
==
3
)
if
(
numberOfAliveNeighbours
==
2
||
numberOfAliveNeighbours
==
3
)
return
true
;
return
true
;
else
else
return
false
;
return
false
;
}
}
else
{
else
{
if
(
numberOfAliveNeighbours
==
3
)
if
(
numberOfAliveNeighbours
==
3
)
return
true
;
return
true
;
else
else
return
false
;
return
false
;
}
}
}
}
}
}
\ 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