SHARE
TWEET

Untitled

a guest May 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class rzutMoneta {
  4.    private int wynik;
  5.  
  6. private int iloscRzutow=0;
  7.  
  8.   public void rzut(){
  9. String [] mozliwosci= new String[2];
  10. mozliwosci[0]="orzel";
  11. mozliwosci[1]="reszka";
  12.  
  13.  
  14.        while (iloscRzutow<5){
  15.             Scanner scan = new Scanner(System.in);
  16.             System.out.println("Orzel czy reszka?");
  17.             String typ = scan.nextLine();
  18.             wynik=(int)(Math.random()*2);
  19.             System.out.println("Twoj wybor to:"+typ);
  20.             System.out.println("Wypadl/a "+ mozliwosci[wynik]);
  21.  
  22.             if(mozliwosci[wynik].equals(typ)){
  23.  
  24.                 System.out.println("Trafiles!!\n");
  25.  
  26.             }
  27.  
  28.             else {
  29.                 System.out.println("Niestety, nie trafiles\n");
  30.             }
  31.  
  32. iloscRzutow++;
  33.  
  34.         }
  35.     }
  36.     }
  37.  
  38.  
  39. class rzutMonetaTest{
  40. public static void main(String[] args){
  41.     System.out.println("Masz piec rzutow moneta.");
  42.     rzutMoneta gra=new rzutMoneta();
  43. gra.rzut();
  44.     System.out.println("Gra zakonczona.");
  45.  
  46.  
  47.  
  48. }}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top