/**
* Created by ttc on 16-11-2.
*/
public class Poke
{
private Card[] m_card = null;
private String[] colors = {"红桃","黑桃","方片","草花"};
private int[] values = {1,2,3,4,5,6,7,8,9,10,11,12,13};
public Poke()
{
m_card = new Card[52];
int index=0;
for(int i = 0; i < colors.length;i++)
{
for (int j = 0; j < values.length; j++)
{
Card c=new Card(values[j],colors[i]);
index++;
//System.out.println(c.toString());
//m_card[i*13+j]=c;
// m_card[i*13+j]=new Card(values[j], colors[i]);
}
}
}
public void outCards()
{
for(int i = 0; i < m_card.length; i++)
{
if(i%13==0)
{
System.out.println();
}
System.out.print(m_card[i].toString()+" ");
}
}
}
package com.company;
/**
* Created by ttc on 16-11-2.
*/
public class Card
{
private int m_iValue;
private String m_strColor;
public Card(int nValue, String strColor)
{
this.m_iValue = nValue;
this.m_strColor = strColor;
}
@Override
public String toString()
{
String strTemp = "";
switch (m_iValue)
{
case 1:
{
strTemp = "A";
break;
}
case 11:
{
strTemp = "J";
break;
}
case 12:
{
strTemp = "Q";
break;
}
case 13:
{
strTemp = "K";
break;
}
default:
{
strTemp = String.valueOf(m_iValue);
}
}
return m_strColor+strTemp;
}
}
package com.company;
/**
* Created by ttc on 16-11-2.
*/
public class Main {
public static void main(String[] args) {
// write your code here
//Card card = new Card(13,"方片");
//System.out.println(card);
Poke p = new Poke();
p.outCards();
}
}