From a1622fa86c352302ae9da827c8ae103d515f5a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kayyissa=20HA=C3=8FSSOUS?= Date: Wed, 5 Apr 2023 16:35:52 +0200 Subject: [PATCH] fix de l'ordre des soumissions --- .../java/com/example/mastermind/game/GameView.java | 1 + .../main/java/com/example/mastermind/game/Grille.java | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/mastermind/game/GameView.java b/app/src/main/java/com/example/mastermind/game/GameView.java index bc872e2..ea789fa 100644 --- a/app/src/main/java/com/example/mastermind/game/GameView.java +++ b/app/src/main/java/com/example/mastermind/game/GameView.java @@ -39,6 +39,7 @@ public class GameView extends View { //affichage des anciennes soumissions LinkedList grille = new LinkedList(); grille.addAll(this.grille.getSoumissions()); + System.out.println(grille.size()); for (int y=0; y<10;y++) { for (int x=0;x<4;x++) { this.circle.setColor(grille.pop()); diff --git a/app/src/main/java/com/example/mastermind/game/Grille.java b/app/src/main/java/com/example/mastermind/game/Grille.java index 8c449fb..5228e2b 100644 --- a/app/src/main/java/com/example/mastermind/game/Grille.java +++ b/app/src/main/java/com/example/mastermind/game/Grille.java @@ -21,11 +21,13 @@ public class Grille { } public void addSoumission(LinkedList newSub){ - for (int i=4;i>0;i--){ - System.out.println("i="+i+", new sub="+newSub); - this.soumissions.set(this.soumissions.size()-this.sizeSubs*4-i,newSub.pop()); + if (this.sizeSubs<10) { + for (int i = 4; i > 0; i--) { + this.soumissions.remove(0); + this.soumissions.addLast(newSub.poll()); + } + this.sizeSubs += 1; } - this.sizeSubs+=1; } public void initGrille(Collection SubToCopy){