Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AzzougLydia AitMouhamedSamy
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
AZZOUG Lydia
AzzougLydia AitMouhamedSamy
Commits
224a6756
Commit
224a6756
authored
4 years ago
by
AZZOUG Lydia
Browse files
Options
Downloads
Patches
Plain Diff
Replace Cell.java
parent
adb13dc8
Branches
undefined
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Cell.java
+29
-30
29 additions, 30 deletions
Cell.java
with
29 additions
and
30 deletions
Cell.java
+
29
−
30
View file @
224a6756
/**
* {@link Cell} instances represent the cells of <i>The Game of Life</i>.
*/
public
class
Cell
{
private
boolean
isAlive
;
public
Cell
(){
private
boolean
isRed
;
public
Cell
(){
this
.
isAlive
=
false
;
}
public
void
setisRed
(
boolean
bool
){
this
.
isRed
=
bool
;
}
public
boolean
isRed
(){
return
this
.
isRed
;
}
/**
* Determines whether this {@link Cell} is alive or not.
*
* @return {@code true} if this {@link Cell} is alive and {@code false} otherwise
*/
public
boolean
isAlive
()
{
return
this
.
isAlive
;
}
...
...
@@ -24,7 +29,6 @@ public class Cell {
*
* @return {@code true} if this {@link Cell} is dead and {@code false} otherwise
*/
public
boolean
isDead
()
{
return
!
this
.
isAlive
;
}
...
...
@@ -32,9 +36,7 @@ public class Cell {
/**
* Sets the state of this {@link Cell} to alive.
*
* @param cellState the new state of this {@link Cell}
*/
public
void
setAlive
()
{
this
.
isAlive
=
true
;
}
...
...
@@ -42,18 +44,14 @@ public class Cell {
/**
* Sets the state of this {@link Cell} to dead.
*
* @param cellState the new state of this {@link Cell}
*/
public
void
setDead
()
{
this
.
isAlive
=
false
;
}
/**
* Change the state of this {@link Cell} from ALIVE to DEAD or from DEAD to ALIVE.
*/
public
void
toggleState
()
{
if
(
this
.
isAlive
)
this
.
isAlive
=
false
;
...
...
@@ -63,7 +61,7 @@ public class Cell {
public
boolean
isAliveInNextState
(
int
numberOfAliveNeighbours
)
{
if
(
isAlive
()){
if
(
numberOfAliveNeighbours
==
2
||
numberOfAliveNeighbours
==
3
)
if
(
(
numberOfAliveNeighbours
==
2
)
||
(
numberOfAliveNeighbours
==
3
)
)
return
true
;
else
return
false
;
...
...
@@ -76,3 +74,4 @@ public class Cell {
}
}
}
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