package com.company;
import java.util.Arrays;
/**
* Created by ttc on 16-11-2.
*/
public class Poke
{
Card[] m_card = null;
int[] values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
String[] colors = {"♡", "♠", "♢", "♧"};
public Poke()
{
m_card = new Card[52];
for (int i = 0; i < colors.length; i++)
{
for (int j = 0; j < values.length; j++)
{
m_card[i * values.length + j] = new Card(values[j], colors[i]);
}
}
}
public void outPut()
{
//展示当前牌序
for (int i = 0; i < m_card.length; i++)
{
if (i % 13 == 0) System.out.println();
System.out.print(m_card[i]);
}
}
public void shuffle()
{
//洗牌
Card tempC = null;
for (int i = 0; i < 52; i++)
{
tempC = m_card[i];
int j = (int) (Math.random() * 51);
m_card[i] = m_card[j];
m_card[j] = tempC;
}
System.out.print("洗牌完成!");
}
public Card[] draw(int n)
{
//抽N张牌
Card[] c = new Card[n];
for (int i = 0; i < n ; i++) c[i] = m_card[i];
return c;
}
public void sortOut(Card[] c)
{
//理牌
Arrays.sort(c);
}
}
|