Skip to content
Snippets Groups Projects
Commit 06062eb1 authored by thest's avatar thest
Browse files

Fix du patron observeateur

parent 2f4e0c2d
No related merge requests found
...@@ -23,6 +23,9 @@ namespace fichier1 ...@@ -23,6 +23,9 @@ namespace fichier1
this.game = partie; this.game = partie;
this.ctrl = new GameController(this.game); this.ctrl = new GameController(this.game);
this.game.Subscribe(this);
this.game.init(5, 2);
} }
public void OnCompleted() public void OnCompleted()
...@@ -38,6 +41,7 @@ namespace fichier1 ...@@ -38,6 +41,7 @@ namespace fichier1
public void OnNext(Partie value) public void OnNext(Partie value)
{ {
Console.WriteLine("Next mot");
pnlContent.Controls.Clear(); pnlContent.Controls.Clear();
pnlContent.Controls.Add(new ViewDecoupage(ctrl)); pnlContent.Controls.Add(new ViewDecoupage(ctrl));
} }
......
...@@ -18,12 +18,20 @@ namespace fichier1.Model ...@@ -18,12 +18,20 @@ namespace fichier1.Model
public Partie(BddContext context) public Partie(BddContext context)
{ {
this.context = context; this.context = context;
this.observers = new List<IObserver<Partie>>();
} }
public void init(int nbMots, float complexite) public void init(int nbMots, float complexite)
{ {
this.nbMots = nbMots; this.nbMots = nbMots;
this.observers = new List<IObserver<Partie>>(); this.motCourant = 0;
this.genererMots(nbMots, complexite);
this.formaterPropositions();
foreach (IObserver<Partie> obs in observers)
{
obs.OnNext(this);
}
} }
public void genererMots(int nb, float complexite) public void genererMots(int nb, float complexite)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment