Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TP;
- import java.util.Random;
- public class tp2 {
- public static int d1;
- public static int d2;
- public static int d3;
- public static int qvu[] = {4, 2, 1};
- public static void main(String[] args) {
- rdmD();
- check();
- //System.out.println("Dé 1 : " + d1 + " Dé 2 : " + d2 + " Dé 3 : " + d3);
- System.out.println(" ");
- }
- public static void rdmD() {
- Random rand = new Random();
- d1 = rand.nextInt(6) + 1;
- d2 = rand.nextInt(6) + 1;
- d3 = rand.nextInt(6) + 1;
- }
- public static void check() {
- int i = 0;
- int j = 0;
- int k = 0;
- int winD1 = 0;
- int winD2 = 0;
- int winD3 = 0;
- while (i < qvu.length && d1 != qvu[i]) {
- i++;
- }
- if(i < qvu.length) {
- System.out.println("Le D1 est tombé sur " + d1);
- winD1 = 1;
- } else {
- System.out.println("Le D1 est tombé sur " + d1);
- }
- while (j < qvu.length && d2 != qvu[j]) {
- j++;
- }
- if(j < qvu.length) {
- System.out.println("Le D2 est tombé sur " + d2);
- winD2 = 1;
- } else {
- System.out.println("Le D2 est tombé sur " + d2);
- }
- while (k < qvu.length && d3 != qvu[k]) {
- k++;
- }
- if(k < qvu.length) {
- System.out.println("Le D3 est tombé sur " + d3);
- winD3 = 1;
- } else {
- System.out.println("Le D3 est tombé sur " + d3);
- }
- if (d1 == d2 || d2 == d3 || d3 == d1) {
- System.out.println("Deux dés ont la même valeur, c'est perdu");
- } else if (winD1 == 1 && winD2 == 1 && winD3 == 1) {
- System.out.println("Vous avez gagné");
- } else {
- System.out.println("C'est perdu");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement