Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package game;
  2.  
  3. public class game {
  4.  
  5. public static void main(String[] args) {
  6. int target = randomNumber();
  7. boolean gameRunning = true;
  8.  
  9. while (gameRunning){
  10. String s=readLine();
  11. int numbers = Integer.parseInt(s);
  12. if (numbers == target){
  13. System.out.println("Gagné");
  14. gameRunning = false;
  15. }
  16. else if(numbers > target){
  17. System.out.println("Essaie encore plus grand mon garçon");
  18. }
  19. else if(numbers < target){
  20. System.out.println("Try again noob, plus petit cette fois ci");
  21. }
  22. }
  23. }
  24.  
  25.  
  26.  
  27. private static String readLine() {
  28. Scanner scanner = new scanner(System.in);
  29. return null;
  30. }
  31.  
  32.  
  33. public static int randomNumber(int min, int max) {
  34.  
  35. // NOTE: Usually this should be a field rather than a method
  36. // variable so that it is not re-seeded every call.
  37. Random rand = new Random();
  38.  
  39. // nextInt is normally exclusive of the top value,
  40. // so add 1 to make it inclusive
  41. int randomNum = rand.nextInt((max - min) + 1) + min;
  42.  
  43. return randomNum;
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement