Bucket Landlord--Jinhua bar--3dmark

Source: Internet
Author: User
Tags shuffle

public class Card {//Poker class
Private String face;
Private String suit;

The value of the card and the color initialization
Public Card (string face, string suit) {
This.face = face;
This.suit = suit;
}

Output card face value and color
Public String toString () {
Return suit + "" + Face;
}

Public String Getface () {
return face;
}

Public String Getsuit () {
return suit;
}

Shuffle the way
public static void Xipai (card[] deck) {
for (int first = 0; first < deck.length; first++) {

int second = (int) (Math.random () * 52);//randomly Generate 0-51 numbers
Card temp = Deck[first]; The variable that represents this class is itself, an object of its own.
Deck[first] = Deck[second];
Deck[second] = temp;
}
}

Licensing
public static void Fapai (card[] deck) {

Card a[] = new card[52];
Card b[] = new card[52];
Card c[] = new card[52];
Card d[] = new card[52];

for (int i = 0; i < deck.length; i + = 4) {
A[i] = Deck[i];
B[i] = deck[i + 1];
C[i] = deck[i + 2];
D[i] = deck[i + 3];
}
int count = 0;
System.out.print ("A player is licensed \ T");
for (int i = 0; i < deck.length; i + = 4) {

System.out.print (A[i] + "\ t");
count++;
if (count% 13 = = 0) {
System.out.println ("");
}

}
System.out.print ("B player licensed \ T");
for (int i = 0; i < deck.length; i + = 4) {
System.out.print (B[i] + "\ t");
count++;
if (count% 13 = = 0) {
System.out.println ("");
}

}
System.out.print ("C player licensed \ T");
for (int i = 0; i < deck.length; i + = 4) {
System.out.print (C[i] + "\ t");
count++;
if (count% 13 = = 0) {
System.out.println ("");
}

}
System.out.print ("D player licensed \ T");
for (int i = 0; i < deck.length; i + = 4) {
System.out.print (D[i] + "\ t");
count++;
if (count% 13 = = 0) {
System.out.println ("");
}

}

}

}

Test class

public class Demo {

public static void Main (string[] args) {

String [] f={"A", "2", "3", "4", "5", "6", "7", "8", "9", "Ten", "J", "Q", "K"};
String s[]={"Spades", "Red Peach", "Plum", "block"};
Card Deck[]=new card[52]; Object array
for (int i = 0; i < deck.length; i++) {
deck[i] = new Card (f[I, s[I/13]);//Each object in the array must be instantiated separately
System.out.println (Deck[i].tostring ());
}
--Shuffle--********************************
Card Gina[]=new card[52];
Card.xipai (deck);
Shuffle the sequence after
for (int i = 0; i < deck.length; i++) {
System.out.println (Deck[i].tostring ());
}

System.out.println ("***************************************************");
for (int i = 0; i < gina.length; i++) {
Gina[i]=deck[i];
}

--Licensing--********************************
Card.fapai (GINA);
The sequence after the card is issued
for (int i = 0; i < deck.length; i++) {
System.out.println (Gina[i].tostring ());
}

}

}

Bucket Landlord--Jinhua bar--3dmark

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.