/
Card.cs
66 lines (57 loc) · 1.51 KB
/
Card.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assign_final
{
public enum CardRank
{
ACE,TWO,THREE,FORE,FIVE,SIX,SEVEN,EIGHT,NINE,TEN,JACK,QUEEN,KING
}
//花色
public enum CardColor
{
HEART, BLACK, DIAMOND, CLUB
}
public class Card
{
readonly CardRank rank;
readonly CardColor color;
//获取点数
public CardRank Rank
{
get{ return rank;}
}
//获取花色
public CardColor Color
{
get { return color; }
}
//显示一张牌
public string Cardstr
{
get
{
return ((char)((int)color+3)).ToString()+" " + rank.ToString();
}
}
public int CardIndex
{
get
{
return ((int)color)*13+(int)rank;
}
}
//无参构造
public Card()
{
rank = (CardRank)0;
color = (CardColor)0;
}
public Card(CardRank rank,CardColor color)
{
this.rank=rank;
this.color=color;
}
}
}