ok
This commit is contained in:
parent
a2062dc88f
commit
d6eee19761
BIN
CASE/Case.class
Normal file
BIN
CASE/Case.class
Normal file
Binary file not shown.
75
CASE/Case.java
Normal file
75
CASE/Case.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// Tom Monin et Clément Martins
|
||||||
|
// paintChoix V1
|
||||||
|
// class pour l'affichage de la selection des lignes, collonnes et nombre de mines
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
public class Case extends JComponent{
|
||||||
|
private boolean visibilite;
|
||||||
|
private boolean bombe;
|
||||||
|
private int voisin;
|
||||||
|
private int suspition;
|
||||||
|
public Case(){
|
||||||
|
this.visibilite=false;
|
||||||
|
this.bombe=false;
|
||||||
|
this.voisin=0;
|
||||||
|
this.suspition=0;
|
||||||
|
}
|
||||||
|
public void setVisibiliter(boolean trueorfalse){
|
||||||
|
this.visibilite=trueorfalse;
|
||||||
|
}
|
||||||
|
public void setBombe(){
|
||||||
|
this.bombe=true;
|
||||||
|
}
|
||||||
|
public void suspition(){
|
||||||
|
this.suspition++;
|
||||||
|
if(this.suspition==3){
|
||||||
|
this.suspition=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics pinceau) {
|
||||||
|
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||||
|
Graphics secondPinceau = pinceau.create();
|
||||||
|
// obligatoire : si le composant n'est pas censé être transparent
|
||||||
|
if (this.isOpaque()) {
|
||||||
|
// obligatoire : on repeint toute la surface avec la couleur de fond
|
||||||
|
secondPinceau.setColor(this.getBackground());
|
||||||
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
}
|
||||||
|
if(this.visibilite==false){
|
||||||
|
secondPinceau.setColor(new Color(100,100,100));
|
||||||
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
|
secondPinceau.setColor(new Color(200, 200, 200));
|
||||||
|
secondPinceau.fillRect(this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18);
|
||||||
|
}
|
||||||
|
if(this.visibilite==true){
|
||||||
|
secondPinceau.setColor(new Color(100,100,100));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
if(this.suspition==1 && this.visibilite==false){
|
||||||
|
int[] x = new int[5];
|
||||||
|
int[] y = new int[5];
|
||||||
|
x[0]=this.getWidth()/2;
|
||||||
|
x[1]=this.getWidth()/10*9;
|
||||||
|
x[2]=this.getWidth()/10*7;
|
||||||
|
x[3]=this.getWidth()/10*3;
|
||||||
|
x[4]=this.getWidth()/10;
|
||||||
|
y[0]=this.getHeight()/10*2;
|
||||||
|
y[1]=this.getHeight()/2;
|
||||||
|
y[2]=this.getHeight()/10*8;
|
||||||
|
y[3]=this.getHeight()/10*8;
|
||||||
|
y[4]=this.getHeight()/2;
|
||||||
|
secondPinceau.setColor(new Color(255,0,125));
|
||||||
|
secondPinceau.fillPolygon(x, y, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
CASE/main_ex.class
Normal file
BIN
CASE/main_ex.class
Normal file
Binary file not shown.
31
CASE/main_ex.java
Normal file
31
CASE/main_ex.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// Tom Monint et Clément Martins
|
||||||
|
// main_ex V1
|
||||||
|
// Classe ayant pour but d'être executer
|
||||||
|
|
||||||
|
//importons les packages necessaires
|
||||||
|
import java.awt.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class main_ex{
|
||||||
|
public static void main(String[] Args){
|
||||||
|
// on initialise une fenettre
|
||||||
|
JFrame fenetre = new JFrame("Démineur");
|
||||||
|
fenetre.setLocation(0,0);
|
||||||
|
//on choisi une taille arbitraire
|
||||||
|
fenetre.setSize(1030,800);
|
||||||
|
//nous utiliserons un gestionnaire GridLayout
|
||||||
|
GridLayout grille = new GridLayout(14,8);
|
||||||
|
fenetre.setLayout(grille);
|
||||||
|
// l'application ne se fermera que si on clique sur
|
||||||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
Case[][] tab = new Case[14][8];
|
||||||
|
for(int i=0; i<14; i++){
|
||||||
|
for(int t=0; t<8; t++){
|
||||||
|
tab[i][t]= new Case();
|
||||||
|
tab[i][t].addMouseListener(new observateurCase(tab[i][t], tab));
|
||||||
|
fenetre.add(tab[i][t]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
CASE/observateurCase.class
Normal file
BIN
CASE/observateurCase.class
Normal file
Binary file not shown.
43
CASE/observateurCase.java
Normal file
43
CASE/observateurCase.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//Tom Monin et Clément Martins
|
||||||
|
// observateurChoix V1
|
||||||
|
//Class pour la selection du nombre de collone et ligne et de Mine a la souris
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class observateurCase implements MouseListener{
|
||||||
|
private Case case1;
|
||||||
|
private Case[][] tableau;
|
||||||
|
public observateurCase(Case case10, Case[][] tableau0){
|
||||||
|
// pour savoir si c'est l'observateur de la fleche de gauche ou droite
|
||||||
|
this.case1=case10;
|
||||||
|
this.tableau=tableau0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent evenement){
|
||||||
|
if(evenement.getButton() == MouseEvent.BUTTON1){
|
||||||
|
case1.setVisibiliter(true);
|
||||||
|
case1.repaint();
|
||||||
|
}
|
||||||
|
if(evenement.getButton() == MouseEvent.BUTTON3){
|
||||||
|
case1.suspition();
|
||||||
|
case1.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override // un bouton cliqué
|
||||||
|
public void mouseEntered(MouseEvent evenement){
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override // debut du survol
|
||||||
|
public void mouseExited(MouseEvent evenement){
|
||||||
|
}
|
||||||
|
@Override // fin du survol
|
||||||
|
public void mousePressed(MouseEvent evenement){
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override // un bouton appuyé
|
||||||
|
public void mouseReleased(MouseEvent evenement){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user