diff --git a/CASE/Case.class b/CASE/Case.class index 5cb8bf3..ed82625 100644 Binary files a/CASE/Case.class and b/CASE/Case.class differ diff --git a/CASE/Case.java b/CASE/Case.java index c32b5af..a039bb3 100644 --- a/CASE/Case.java +++ b/CASE/Case.java @@ -11,11 +11,13 @@ public class Case extends JComponent{ private boolean bombe; private int voisin; private int suspition; + private Image interogation; public Case(){ this.visibilite=false; this.bombe=false; this.voisin=0; this.suspition=0; + this.interogation= Toolkit.getDefaultToolkit().getImage("./IMAGE/pointintero.png"); } public void setVisibiliter(boolean trueorfalse){ this.visibilite=trueorfalse; @@ -29,6 +31,19 @@ public class Case extends JComponent{ this.suspition=0; } } + public boolean getBombe(){ + return this.bombe; + } + public void setVoisin(int nvoisin){ + this.voisin=nvoisin; + } + public boolean getSuspition(){ + if(this.suspition>0){ + return true; + }else{ + return false; + } + } @Override protected void paintComponent(Graphics pinceau) { // obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard @@ -50,11 +65,12 @@ public class Case extends JComponent{ secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); secondPinceau.setColor(new Color(255, 255, 255)); secondPinceau.fillRect(this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18); - secondPinceau.setColor(new Color(255,0,0)); - } - if(this.voisin>0){ - secondPinceau.drawString("3", this.getWidth()/2, this.getHeight()/2); + secondPinceau.setColor(new Color(255, 0, 0)); + if(this.voisin>0){ + secondPinceau.drawString(String.valueOf(voisin), this.getWidth()/2, this.getHeight()/2); + } } + if(this.suspition==1 && this.visibilite==false){ int[] x = new int[5]; int[] y = new int[5]; @@ -71,5 +87,12 @@ public class Case extends JComponent{ secondPinceau.setColor(new Color(255,0,125)); secondPinceau.fillPolygon(x, y, 5); } + if(this.suspition==2 && this.visibilite==false){ + secondPinceau.drawImage(this.interogation, this.getWidth()/10, this.getHeight()/10, this.getWidth()/10*5, this.getHeight()/10*5 ,this); + } + if(this.bombe==true && this.visibilite==true){ + secondPinceau.setColor(new Color(255,0,125)); + secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); + } } } \ No newline at end of file diff --git a/CASE/IMAGE/pointintero.png b/CASE/IMAGE/pointintero.png new file mode 100644 index 0000000..651da3e Binary files /dev/null and b/CASE/IMAGE/pointintero.png differ diff --git a/CASE/main_ex.class b/CASE/main_ex.class index 1dfb45b..f6623ec 100644 Binary files a/CASE/main_ex.class and b/CASE/main_ex.class differ diff --git a/CASE/main_ex.java b/CASE/main_ex.java index 661cb2f..ff69f1a 100644 --- a/CASE/main_ex.java +++ b/CASE/main_ex.java @@ -27,5 +27,8 @@ public class main_ex{ fenetre.add(tab[i][t]); } } + plateau plat = new plateau(tab); + plat.setAllBombe(18, 14, 8); + plat.setAllVoisin(); } } \ No newline at end of file diff --git a/CASE/observateurCase.class b/CASE/observateurCase.class index a4eb7f7..aac4ed2 100644 Binary files a/CASE/observateurCase.class and b/CASE/observateurCase.class differ diff --git a/CASE/observateurCase.java b/CASE/observateurCase.java index af4e9b5..42ad837 100644 --- a/CASE/observateurCase.java +++ b/CASE/observateurCase.java @@ -16,8 +16,10 @@ public class observateurCase implements MouseListener{ @Override public void mouseClicked(MouseEvent evenement){ if(evenement.getButton() == MouseEvent.BUTTON1){ - case1.setVisibiliter(true); - case1.repaint(); + if(case1.getSuspition()==false){ + case1.setVisibiliter(true); + case1.repaint(); + } } if(evenement.getButton() == MouseEvent.BUTTON3){ case1.suspition(); diff --git a/CASE/plateau.class b/CASE/plateau.class new file mode 100644 index 0000000..1a2a385 Binary files /dev/null and b/CASE/plateau.class differ diff --git a/CASE/plateau.java b/CASE/plateau.java new file mode 100644 index 0000000..5101403 --- /dev/null +++ b/CASE/plateau.java @@ -0,0 +1,69 @@ +import java.util.*; + +public class plateau{ + private Case[][] tableau; + public plateau(Case[][] tableau0){ + this.tableau=tableau0; + } + + public void setAllBombe(int nombre, int ligne, int collonne){ + Random rand = new Random(); + for(int i=0; i0){ + if(tableau[i-1][t].getBombe()==true){ + voisin++; + } + if(t>0){ + if(tableau[i-1][t-1].getBombe()==true){ + voisin++; + } + } + if(t0){ + if(tableau[i+1][t-1].getBombe()==true){ + voisin++; + } + } + if(t0){ + if(tableau[i][t-1].getBombe()==true){ + voisin++; + } + } + if(t