Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Game of life Template
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
YAGOUBI Rim
Game of life Template
Commits
9471d988
Commit
9471d988
authored
1 year ago
by
Guyslain
Browse files
Options
Downloads
Patches
Plain Diff
section 5 State fini
parent
cb86aaef
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/model/State.java
+9
-4
9 additions, 4 deletions
src/main/java/model/State.java
src/test/java/model/automata/GameOfLifeStateTest.java
+2
-3
2 additions, 3 deletions
src/test/java/model/automata/GameOfLifeStateTest.java
with
11 additions
and
7 deletions
src/main/java/model/State.java
+
9
−
4
View file @
9471d988
...
...
@@ -21,11 +21,11 @@ public interface State<S> {
Color
getColor
();
/**
* Computes and returns the
next
state b
ased on the rules of the cellular automaton.
* Computes and returns the state
s
b
y cycling through each possible state
*
* @return The next state.
*/
S
next
();
S
cycle
();
/**
* Updates the state based on the states of its neighboring cells.
...
...
@@ -44,7 +44,12 @@ public interface State<S> {
* @return The number of times the specified state appears in the list of neighbors.
*/
static
<
T
>
int
count
(
T
state
,
List
<
T
>
neighbours
)
{
//TODO: à compléter
return
0
;
int
count
=
0
;
for
(
T
element
:
neighbours
)
{
if
(
element
.
equals
(
state
))
{
count
=
count
+
1
;
}
}
return
count
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/test/java/model/automata/GameOfLifeStateTest.java
+
2
−
3
View file @
9471d988
package
model.automata
;
import
javafx.scene.paint.Color
;
import
model.State
;
import
org.junit.jupiter.api.Test
;
import
java.util.List
;
...
...
@@ -18,8 +17,8 @@ class GameOfLifeStateTest {
@Test
public
void
testNext
()
{
assertEquals
(
ALIVE
.
next
(),
DEAD
);
assertEquals
(
DEAD
.
next
(),
ALIVE
);
assertEquals
(
ALIVE
.
cycle
(),
DEAD
);
assertEquals
(
DEAD
.
cycle
(),
ALIVE
);
}
@Test
...
...
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