SAE21_2022/TEMP.txt

82 lines
3.1 KiB
Plaintext
Raw Normal View History

import java.awt.event.*;
public class Modifications implements MouseListener {
// Def Constante
public static final int COULOIR=0;
public static final int MUR=1;
public static final int ENTREE=2;
public static final int SORTIE=3;
public static final boolean OCCUPE = false;
public static final boolean LIBRE = true;
// Def variable
private boolean[][] grilleTab ;
private int[] ceTab ;
private PanneauModification options;
private int cetteLigne = 0;
private int cetteColone = 0;
private int ceType = 0;
private int grilleType;
private int cellulesBleu = 0;
private int cellulesRouge = 0;
public Modifications(PanneauModification panneauModification, boolean[][] grilleTab, int[] unTab){
this.options = panneauModification;
this.grilleTab = grilleTab;
this.ceTab = unTab;
}
public void mouseClicked(MouseEvent e) {
Cellules notreCellule = (Cellules) e.getSource();
this.cetteLigne = notreCellule.getLigne();
this.cetteColone = notreCellule.getColone();
this.ceType = notreCellule.getType();
// Accéder aux boutons radios de l'objet Options
boolean radio1Selected = options.GetButtonBW().isSelected(); // MUR / COULOIR
boolean radio2Selected = options.GetButtonE().isSelected(); // ENTREE
boolean radio3Selected = options.GetButtonS().isSelected(); //SORTIE
if(this.grilleTab[this.cetteLigne][this.cetteColone] == false && this.ceType==MUR && radio1Selected==true){
this.grilleTab[this.cetteLigne][this.cetteColone] = LIBRE;
notreCellule.setType(COULOIR);
System.out.println("voici le type de la case : "+ notreCellule.getType());
} else if(this.grilleTab[this.cetteLigne][this.cetteColone] == true && this.ceType==COULOIR && radio1Selected==true){
this.grilleTab[this.cetteLigne][this.cetteColone] = OCCUPE;
notreCellule.setType(MUR);
} else if(radio2Selected==true && this.ceTab[0] == 0){
this.grilleTab[this.cetteLigne][this.cetteColone] = LIBRE;
notreCellule.setType(ENTREE);
this.ceTab[0] = 1;
} else if(radio3Selected==true && this.ceTab[1] == 0){
this.grilleTab[this.cetteLigne][this.cetteColone] = LIBRE;
notreCellule.setType(SORTIE);
this.ceTab[0] = 1;
} else if(this.ceTab[0] == 1 && this.ceType==ENTREE && radio1Selected==true){
this.ceTab[0] = 0;
} else if(this.ceTab[1] == 1 && this.ceType==SORTIE && radio1Selected==true){
this.ceTab[1] = 0;
}
System.out.println("etat de la case maintenant : "+this.grilleTab[this.cetteLigne][this.cetteColone]);
}
public int[] getValues(){
return this.ceTab;
}
// Les méthodes suivantes ne sont pas utilisées dans cet exemple, donc nous les laissons vides
public void mouseExited(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
}