Ajout du test 1 à partir de rien : Makefile, Bakefile, Test1 et Devinette
This commit is contained in:
parent
ad19cecc45
commit
89d55c43e3
tests/Java/test-01-from-nothing
7
tests/Java/test-01-from-nothing/Bakefile
Normal file
7
tests/Java/test-01-from-nothing/Bakefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
all: test1 Devinette
|
||||||
|
|
||||||
|
test1: test1.java
|
||||||
|
javac test1.java
|
||||||
|
|
||||||
|
Devinette: Devinette.java
|
||||||
|
javac Devinette.java
|
36
tests/Java/test-01-from-nothing/Devinette.java
Normal file
36
tests/Java/test-01-from-nothing/Devinette.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Devinette {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
Random random = new Random();
|
||||||
|
int nombreMystere = random.nextInt(100) + 1; // Nombre entre 1 et 100
|
||||||
|
int essais = 5;
|
||||||
|
boolean gagne = false;
|
||||||
|
|
||||||
|
System.out.println("Bienvenue dans le jeu de devinette !");
|
||||||
|
System.out.println("Essayez de deviner le nombre mystère entre 1 et 100. Vous avez " + essais + " tentatives.");
|
||||||
|
|
||||||
|
for (int i = 0; i < essais; i++) {
|
||||||
|
System.out.print("Entrez votre tentative : ");
|
||||||
|
int tentative = scanner.nextInt();
|
||||||
|
|
||||||
|
if (tentative == nombreMystere) {
|
||||||
|
System.out.println("Bravo ! Vous avez trouvé le nombre mystère.");
|
||||||
|
gagne = true;
|
||||||
|
break;
|
||||||
|
} else if (tentative < nombreMystere) {
|
||||||
|
System.out.println("Trop bas ! Essayez encore.");
|
||||||
|
} else {
|
||||||
|
System.out.println("Trop haut ! Essayez encore.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gagne) {
|
||||||
|
System.out.println("Dommage ! Le nombre mystère était : " + nombreMystere);
|
||||||
|
}
|
||||||
|
|
||||||
|
scanner.close();
|
||||||
|
}
|
||||||
|
}
|
7
tests/Java/test-01-from-nothing/Makefile
Normal file
7
tests/Java/test-01-from-nothing/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
all: test1 Devinette
|
||||||
|
|
||||||
|
test1: test1.java
|
||||||
|
javac test1.java
|
||||||
|
|
||||||
|
Devinette: Devinette.java
|
||||||
|
javac Devinette.java
|
6
tests/Java/test-01-from-nothing/test1.java
Normal file
6
tests/Java/test-01-from-nothing/test1.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
public class test1 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Compilation à partir de rien !");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user