Guest User

Untitled

a guest
Dec 12th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package net.matesco.hry.tajnecislo;
  2.  
  3. import java.util.Random;
  4. import java.util.Scanner;
  5.  
  6. public class HlavniTrida {
  7.  
  8.     public static void main(String[] args) {
  9.         int body = 0, cislo, cislo2;
  10.         boolean spustenost = true;
  11.         Scanner in = new Scanner(System.in);
  12.         System.out.println("Myslim si cislo od 1 do 10, zkus ho uhadnout! :)");
  13.         while(spustenost == true){
  14.         System.out.print("Hadane cislo: ");
  15.         cislo2 = in.nextInt();
  16.         Random rnd = new Random();
  17.         cislo = rnd.nextInt(10);
  18.         if(cislo == cislo2){
  19.             System.out.println("Trefa! :)");
  20.             System.out.println("+1 bod, tvoje body = " + body);
  21.             body++; }
  22.         else
  23.             System.out.println("Nene! :(");
  24.         if(body == 10){
  25.             System.out.println("Vyhral jsi! Gratuluji! :)");
  26.             spustenost = false;
  27.         }
  28.     }
  29.     }
  30. }
Add Comment
Please, Sign In to add comment