public class Main {
public static void main(String[] args)
{
Poker p = new Poker();
p.flush();
p.getCard(1);
}
}
public class Card
{
private int m_values;
private String m_color;
public Card(int m_values, String m_color)
{
this.m_values = m_values;
this.m_color = m_color;
}
@Override
public String toString()
{
//为了什么写
String str = null;
switch (m_values)
{
case 1:
{
str = "A";
break;
}
case 11:
{
str = "J";
break;
}
case 12:
{
str = "Q";
break;
}
case 13:
{
str = "K";
break;
}
default:
str = String.valueOf(m_values);
}
return str + m_color ;
}
}
public class Poker
{
private Card[] poker = null;
private int[] value = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
private String[] color = {"♡", "♠", "♢", "♧"};
public Poker()
{
poker = new Card[52];
for (int i = 0; i < value.length; i++)
for (int j = 0; j < color.length; j++)
{
poker[i * color.length + j] = new Card(value[i], color[j]);
}
}
public void out()
{
for (int n = 0; n < poker.length; n++)
{
System.out.println(poker[n]+" "+n);
}
}
public void flush()
{
for(int x = 0 ; x <100;x++)
{
int a = (int) (Math.random() * 52);
int b = (int) (Math.random() * 52);
Card temp = null;
temp = poker[a];
poker[a] = poker[b];
poker[b] = temp;
}
}
public void getCard(int v)
{
int arr[] = new int[v];
for(int i =0;i<v;i++)
{
arr[i] = (int)(Math.random()*51);
for(int n =0; n<i ;n++)
{
if (arr[i]==arr[n])
{
arr[i] = (int)(Math.random()*51);
}
}
}
for(int i =0;i<v;i++)
{
System.out.println(poker[arr[i]]);
}
}
}