Guest User

Untitled

a guest
Apr 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Roll20
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         int[] success=new int[Integer.parseInt(System.getenv("COLUMNS"))];
  8.         int max=Integer.parseInt(System.getenv("LINES"))-1;
  9.        
  10.         Random rand=new Random();
  11.         boolean donezo=false;
  12.         while (!donezo)
  13.         {
  14.             int roll=0;
  15.             while (rand.nextInt(20)!=0) roll++;
  16.            
  17.             if (roll<success.length)
  18.             {
  19.                 success[roll]++;
  20.                 if (success[roll]==max) donezo=true;
  21.             }
  22.         }
  23.        
  24.         for (int row=max; row>0; row--)
  25.             for (int x=0; x<success.length; x++)
  26.                 System.out.print(row<=success[x]?"X":" ");
  27.     }
  28. }
Add Comment
Please, Sign In to add comment