Skip to content
Snippets Groups Projects
Commit 066f51b0 authored by Sami Zouari's avatar Sami Zouari
Browse files

question 6 finie

parent 2b963075
No related branches found
No related tags found
No related merge requests found
......@@ -12,27 +12,33 @@ public class Ecouteur implements EventHandler<ActionEvent> {
private Label label1;
private Label label2;
private Label label3;
private Label label4;
private int nb421 = 0;
private int nbCoups = 1;
private Random random = new Random();
public Ecouteur(){}
public Ecouteur(Label l1, Label l2, Label l3){
public Ecouteur(Label l1, Label l2, Label l3, Label l4){
this.label1 = l1;
this.label2 = l2;
this.label3 = l3;
this.label4 = l4;
}
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("Bienvenue dans le Jeu !");
System.out.println("Nombre de clicks : " + compteur);
System.out.println("Bienvenue dans le Jeu !"); //Question 2
System.out.println("Nombre de clicks : " + compteur); //Question 3
compteur += 1;
int n, x, y;
n = random.nextInt(7);
n = random.nextInt(7); //Question 5
x = random.nextInt(7);
y = random.nextInt(7);
......@@ -40,5 +46,15 @@ public class Ecouteur implements EventHandler<ActionEvent> {
label2.setText(""+ x);
label3.setText(""+ y);
if(n == 4 && x == 2 && y == 1){
nb421 += 1;
}
//Question 6
label4.setText("Nombre de fois ou 421 est apparu : " + nb421 + " Nombre de coups joués : " + nbCoups);
nbCoups += 1;
}
}
......@@ -17,21 +17,25 @@ public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
/* question 1 */
stage.setTitle("Titre TP!");
stage.setTitle("Titre TP!"); //Question 1
BorderPane border = new BorderPane();
Button bouton = new Button("Jouer");
HBox box = new HBox();
HBox box2 = new HBox();
Label l1 = new Label("1");
Label l1 = new Label("1"); //Question 4
Label l2 = new Label("1");
Label l3 = new Label("1");
Label l4 = new Label("Nombre de fois ou 421 est apparu : 0 Nombre de coups joués : 0");
box.getChildren().addAll(l1, l2, l3);
box2.getChildren().addAll(l4);
border.setCenter(box);
border.setBottom(bouton);
bouton.setOnAction(new Ecouteur(l1,l2,l3));
border.setTop(box2);
bouton.setOnAction(new Ecouteur(l1,l2,l3, l4));
Scene scene = new Scene(border, 400, 400);
stage.setScene(scene);
stage.show();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment