Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain De Laage De Bellefaye
LO21-projet
Commits
96cba7be
Commit
96cba7be
authored
May 27, 2021
by
Victor Blanchet
Browse files
Update reseau_cellule_etats.cpp
parent
7049fe9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Reseau_Cellule_Etat/reseau_cellule_etats.cpp
View file @
96cba7be
#include
"reseau_cellule_etats.h"
#include
<iostream>
#include
<iomanip>
#include
<cstdlib>
extern
EnsembleEtat
&
enseEtats
;
using
namespace
std
;
...
...
@@ -70,6 +73,9 @@ void Cellule::initCellule(const unsigned int ind, const unsigned int &x, const u
this
->
ord
=
y
;
}
void
Cellule
::
incrementerEtat
(){
indEtat
=
(
indEtat
+
1
)
%
enseEtats
.
getNbEtats
();}
//méthodes de la classe Reseau
Reseau
::
Reseau
(
const
unsigned
int
&
h
,
const
unsigned
int
&
l
)
:
hauteur
(
h
),
largeur
(
l
){
...
...
@@ -95,3 +101,29 @@ void Reseau::affiche(){
std
::
cout
<<
"
\n
"
;
}
}
Reseau
&
Reseau
::
setAleatoire
(){
srand
(
time
(
NULL
));
for
(
unsigned
int
i
=
0
;
i
<
hauteur
;
i
++
)
for
(
unsigned
int
j
=
0
;
j
<
largeur
;
j
++
)
{
unsigned
int
random_ind
=
rand
()
%
(
enseEtats
.
getNbEtats
());
reseau
[
i
][
j
].
initCellule
(
random_ind
,
i
,
j
);
};
return
*
this
;
}
Reseau
::
Reseau
(
Reseau
&
init_grille
){
hauteur
=
init_grille
.
hauteur
;
largeur
=
init_grille
.
largeur
;
reseau
=
new
Cellule
*
[
hauteur
];
for
(
unsigned
int
i
=
0
;
i
<
hauteur
;
i
++
)
reseau
[
i
]
=
new
Cellule
[
largeur
];
for
(
unsigned
int
i
=
0
;
i
<
hauteur
;
i
++
)
for
(
unsigned
int
j
=
0
;
j
<
largeur
;
j
++
)
{
reseau
[
i
][
j
].
initCellule
(
init_grille
.
reseau
[
i
][
j
].
getIndEtat
(),
i
,
j
);
}
};
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment