Created
February 14, 2020 17:33
-
-
Save pingsutw/2a637800ce28c409cdf5df74dfe5af3e to your computer and use it in GitHub Desktop.
Generate random deck card
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.Scanner; | |
import java.util.Random; | |
public class generate_card { | |
public static void main (String[] args) { | |
Scanner scan = new Scanner (System.in); | |
int num_decks = scan.nextInt(); | |
int num_perDecks = scan.nextInt(); | |
//String suits[] = {"H","D","C","S"}; | |
String suits[] = {"\u2661", "\u2662", "\u2663", "\u2660"}; | |
String cards[] = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"}; | |
for(int i=0;i<num_decks;i++){ | |
for(int j=0;j<num_perDecks;j++){ | |
Random random = new Random (); | |
int num = random.nextInt (cards.length * suits.length); | |
System.out.print(cards[num % cards.length] + suits[num / cards.length]); | |
System.out.print(" "); | |
} | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment