Last active
August 29, 2015 14:14
-
-
Save JuanjoSalvador/8c6d0dd5000945880bac to your computer and use it in GitHub Desktop.
Dados personalizados
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
package rollingDices; | |
import java.io.*; | |
public class RollingDices { | |
String[] dice_one = {"Action 1", "Action 2", "Action 3", "Action 4", "Action 5", "Action 6"}; // Primer dado | |
String[] dice_two = {"Action 1", "Action 2", "Action 3", "Action 4", "Action 5", "Action 6"}; // Segundo dado | |
public String diceOne() { // Tira el primer dado y devuelve el resultado | |
int rolling_one = (int)(Math.random() * 6); | |
return dice_one[rolling_one]; | |
} | |
public String diceTwo() { // Tira el segundo dado y devuelve el resultado | |
int rolling_two = (int)(Math.random() * 6); | |
return dice_two[rolling_two]; | |
} | |
public boolean reroll() { // Devuelve true si se repite la tirada, false si no. Condiciona un do while en el main | |
String rep = null; | |
InputStreamReader reader = new InputStreamReader(System.in); | |
BufferedReader in = new BufferedReader(reader); | |
rep = in.readLine(); | |
return rep.equals(""); | |
} | |
public void test() { // Imprime los resultados de las tiradas | |
System.out.println(diceOne() + " " + diceTwo()); | |
System.out.println(" "); | |
System.out.print("Repeat? Press <Enter> to repeat."); | |
System.out.println(" "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Código autocomentado. Se trata de un juego de dados completamente personalizables.