correction Case

This commit is contained in:
Haïssous Kayyissa 2022-05-04 19:53:32 +02:00
parent fd598eeb07
commit df2232c155
5 changed files with 13 additions and 23 deletions

View File

@ -22,10 +22,19 @@ public class Case extends JPanel {
GridLayout unique = new GridLayout(1,1);
this.setLayout(unique);
this.setBackground(new Color(70, 70, 70));
}
public void setVisible(){
this.visible=true;
if (this.minee == true) {
this.setBackground(new Color(236, 0, 140));
} else {
this.setBackground(new Color(80, 80, 80));
if (this.entourage>0){
this.add(new Chiffre(entourage,caseSize));
}
}
this.updateUI();
}
@ -33,21 +42,7 @@ public class Case extends JPanel {
return this.visible;
}
public Case getCase(){
if (this.visible == false) {
this.setBackground(new Color(70, 70, 70));
} else if (this.visible == true) {
if (this.minee == true) {
this.setBackground(new Color(236, 0, 140));
} else {
this.setBackground(new Color(80, 80, 80));
if (this.entourage>0){
this.add(new Chiffre(entourage,caseSize));
}
}
}
return this;
}
public boolean getMine(){
return this.minee;

View File

@ -3,7 +3,7 @@ import java.awt.*;
// Cette classe à pour but d'afficher un menu et de réagir aux directives de l'utilisateur (lancer le jeu, le quitter...)
public class FrameJeu{
public FrameJeu(Grille grille, int mines) {
public FrameJeu(Grille grille) {
// On récupère les dimensions de l'écran pour adapter la taille par défaut de notre fenêtre
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

View File

@ -267,7 +267,7 @@ public class Grille extends JPanel {
protected void AfficherPlateau(int taille, Dimension caseSize, int[] entourage, boolean[] minee){
for (int i=0;i<taille;i++){
this.plateau[i]= new Case(caseSize,minee[i],entourage[i]);
this.add(this.plateau[i].getCase());
this.add(this.plateau[i]);
}
}

View File

@ -9,7 +9,6 @@ public class Listener implements MouseListener{
Case panel = (Case)evenement.getSource();
if ((evenement.getButton() == MouseEvent.BUTTON1)&&(panel.getVisible()==false)&&(this.marquage==0)){
panel.setVisible();
panel.getCase();
if (panel.getMine()==true){
System.out.println("Perdu!");
}
@ -34,16 +33,12 @@ public class Listener implements MouseListener{
}
}
public void mouseEntered(MouseEvent evenement){
// System.out.println("mouseEntered");
}
public void mouseExited(MouseEvent evenement){
// System.out.println("mouseExited");
}
public void mousePressed(MouseEvent evenement){
// System.out.println("mousePressed");
}
public void mouseReleased(MouseEvent evenement){
// System.out.println("mouseReleased");
}
}

View File

@ -1,6 +1,6 @@
public class Test {
public static void main(String[] args) {
Grille grille=new Grille(10,15,15);
new FrameJeu(grille, 15);
new FrameJeu(grille);
}
}