Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fardale
Prog2
Commits
c79e2572
Commit
c79e2572
authored
Mar 20, 2015
by
William Babonnaud
Browse files
Petites modifs dans flip (victoire, nom de classe)
Ajout de test.scala, qui gère le jeu flip
parent
7160c234
Changes
1
Hide whitespace changes
Inline
Side-by-side
flip.scala
View file @
c79e2572
...
...
@@ -2,14 +2,19 @@ import scala.util.Random
import
Array._
import
java.awt.Color
class
f
lip
{
class
F
lip
{
// Cotés du terrain.
private
var
tailleX
=
5
private
var
tailleY
=
5
def
getTailleX
=
tailleX
def
getTailleY
=
tailleY
// Matrice des boutons.
var
boutons
=
ofDim
[
MonBouton
](
tailleX
,
tailleY
)
def
getBoutons
(
x
:
Int
,
y
:
Int
)
=
boutons
(
x
)(
y
)
// Pour reparamétrer la configuration du terrain
def
reparametrage
(
x
:
Int
,
y
:
Int
)
=
{
tailleX
=
x
...
...
@@ -71,13 +76,14 @@ class flip {
}
// Renvoire true si toutes les cases du terrain sont blanches
def
victoire
:
Boolean
=
{
def
victoire
=
{
var
res
=
true
/* !!! */
for
(
i
<-
0
to
(
tailleX
-
1
))
{
for
(
j
<-
0
to
(
tailleY
-
1
))
{
if
(!
boutons
(
i
)(
j
).
estLibre
)
{
false
}
res
=
(
res
&&
boutons
(
i
)(
j
).
estLibre
)
}
}
true
res
}
// Conséquence du clic d'un bouton.
...
...
@@ -87,7 +93,7 @@ class flip {
if
(
i
<
tailleX
-
1
)
{
chgBouton
(
i
+
1
,
j
)
}
if
(
j
>
0
)
{
chgBouton
(
i
,
j
-
1
)
}
if
(
j
<
tailleY
-
1
)
{
chgBouton
(
i
,
j
+
1
)
}
victoire
false
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment