Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package game;
- public class game {
- public static void main(String[] args) {
- int target = randomNumber();
- boolean gameRunning = true;
- while (gameRunning){
- String s=readLine();
- int numbers = Integer.parseInt(s);
- if (numbers == target){
- System.out.println("Gagné");
- gameRunning = false;
- }
- else if(numbers > target){
- System.out.println("Essaie encore plus grand mon garçon");
- }
- else if(numbers < target){
- System.out.println("Try again noob, plus petit cette fois ci");
- }
- }
- }
- private static String readLine() {
- Scanner scanner = new scanner(System.in);
- return null;
- }
- public static int randomNumber(int min, int max) {
- // NOTE: Usually this should be a field rather than a method
- // variable so that it is not re-seeded every call.
- Random rand = new Random();
- // nextInt is normally exclusive of the top value,
- // so add 1 to make it inclusive
- int randomNum = rand.nextInt((max - min) + 1) + min;
- return randomNum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement