Created
February 16, 2018 23:02
-
-
Save GreyHat147/0b81dca8fa5150a494bc47a699ffdf50 to your computer and use it in GitHub Desktop.
GAME JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Game { | |
public static void main(String args[]) { | |
int car1 = 100, car2 = 100; | |
int result = 0; | |
while (true){ | |
Random random = new Random(); | |
int r = random.nextInt(100 - 0 + 1) + 0; | |
if (car1 >= r) { | |
car1 = car1 - r; | |
if (car1 == 0) { | |
result = 1; | |
break; | |
} | |
} | |
Random random2 = new Random(); | |
int r2 = random2.nextInt(100 - 0 + 1) + 0; | |
if (car2 >= r2) { | |
car2 = car2 - r2; | |
if (car2 == 0) { | |
result = 2; | |
break; | |
} | |
} | |
} | |
System.out.println("El carro numero # " + result + " ha gando la carrera"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment