Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class TwentyOne {
- int card1;
- public static void main(String a[]){
- // Generates a random number between 1 and 13
- card1 = getRandomInteger(13, 1);
- System.out.println("Dealer: "
- + card1);
- }
- /*
- * Java method to return random integer between 0 and
- * given number. Pay attention to brackets while casting
- * (int) Math.random*max will return incorrect result.
- */
- public static int getRandom(int max){
- return (int) (Math.random()*max);
- }
- /*
- * returns random integer between minimum and maximum range
- */
- public static int getRandomInteger(int maximum, int minimum){
- return ((int) (Math.random()*(maximum - minimum))) + minimum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement