Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tp6 Flood
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
EL GAOUAL Zaid
Tp6 Flood
Commits
fe63ef3b
Commit
fe63ef3b
authored
2 years ago
by
EL GAOUAL Zaid
Browse files
Options
Downloads
Patches
Plain Diff
ColorGenerator
parent
815b510c
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
app/src/main/java/model/UniformColorGenerator.java
+1
-1
1 addition, 1 deletion
app/src/main/java/model/UniformColorGenerator.java
app/src/main/java/model/UniformExceptOneGenerator.java
+20
-3
20 additions, 3 deletions
app/src/main/java/model/UniformExceptOneGenerator.java
with
21 additions
and
4 deletions
app/src/main/java/model/UniformColorGenerator.java
+
1
−
1
View file @
fe63ef3b
...
...
@@ -5,7 +5,7 @@ import javafx.scene.paint.Color;
public
class
UniformColorGenerator
implements
ColorGenerator
{
private
Color
color
;
public
UniformColorGenerator
(
Color
color
){
this
.
color
=
color
;
this
.
color
=
color
;
}
public
Color
nextColor
(
Cell
cell
)
{
return
this
.
color
;
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/model/UniformExceptOneGenerator.java
+
20
−
3
View file @
fe63ef3b
...
...
@@ -2,14 +2,31 @@ package model;
import
javafx.scene.paint.Color
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Random
;
public
class
UniformExceptOneGenerator
implements
ColorGenerator
{
public
Color
uniformColor
;
public
Color
exceptionColor
;
public
int
chosen
=
0
;
public
UniformExceptOneGenerator
(
Color
uniformColor
,
Color
exceptionColor
)
{
this
.
uniformColor
=
uniformColor
;
this
.
exceptionColor
=
exceptionColor
;
}
@Override
public
Color
nextColor
(
Cell
cell
)
{
return
null
;
if
(
chosen
==
0
)
{
List
<
Color
>
colors
=
Arrays
.
asList
(
uniformColor
,
exceptionColor
);
Random
rand
=
new
Random
();
Color
randomColor
=
colors
.
get
(
rand
.
nextInt
(
colors
.
size
()));
if
(
randomColor
==
exceptionColor
)
{
chosen
+=
1
;
}
return
randomColor
;
}
else
{
return
uniformColor
;
}
}
}
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