Skip to content

Instantly share code, notes, and snippets.

@edhedges
Created November 29, 2011 14:26
Show Gist options
  • Save edhedges/1404972 to your computer and use it in GitHub Desktop.
Save edhedges/1404972 to your computer and use it in GitHub Desktop.
Card class
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