Created
November 29, 2011 14:26
-
-
Save edhedges/1404972 to your computer and use it in GitHub Desktop.
Card class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace HedgesBlackjack | |
{ | |
public enum Suits | |
{ | |
S = 1, H, C, D | |
} | |
public class Card | |
{ | |
private bool _faceUp = true; | |
private Suits _suit; | |
private int _rank; | |
static readonly string[] rankGiver = {"T", "J", "Q", "K", "A"}; | |
public Card(Suits s, int r) | |
{ | |
_suit = s; | |
_rank = r; | |
} | |
public override string ToString() | |
{ | |
if (_faceUp == false) return "XX"; | |
if (_rank > 9) return rankGiver[_rank - 10] + _suit.ToString(); | |
else return _rank.ToString() + _suit.ToString(); | |
} | |
public Suits Suit | |
{ | |
get | |
{ | |
return _suit; | |
} | |
} | |
public int Value | |
{ | |
get | |
{ | |
return _rank; | |
} | |
} | |
public bool FaceUp | |
{ | |
set | |
{ | |
_faceUp = value; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment