Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.util.*;
  2. public class tagil1
  3. {
  4. public static void main(String[] args){
  5. int[] arr = new int[30];
  6. Scanner in = new Scanner(System.in);
  7. for( int i= 0; i<1; i++){
  8. int rnd = (int)(Math.random()*29+1);
  9. arr[rnd] = 1;
  10. }
  11.  
  12. int place = 0;
  13. while(place<30){
  14. int cube = (int)(Math.random()*6+1);
  15. System.out.println("cube: "+cube);
  16. place += cube;
  17. if(place < 30){
  18. if (arr[place] == 1){
  19. place =30;
  20. System.out.println("you died");
  21. }
  22. else if (place>=30){
  23. System.out.println("you win");
  24. }
  25. else{
  26. System.out.println("your place is: " + place);
  27. }
  28. }
  29. else System.out.println("you win");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement