Exemplo n.º 1
0
        public static Bid FromString(string bidString)
        {
            if (bidString == null)
            {
                throw new ArgumentNullException("bidString");
            }
            if (bidString.Trim().Length < 2)
            {
                throw new ArgumentException("Bid must be in the form NumberOfTricks Suit");
            }
            string trickString = bidString.TrimStart().Substring(0, 1);
            string suitString  = bidString.TrimStart().Substring(1).Trim();
            int    tricks;

            if (!int.TryParse(trickString, out tricks))
            {
                throw new ArgumentException("First part of bid must be an integer");
            }
            Suit suit = Card.SuitFromString(suitString);

            return(new Bid(tricks, suit));
        }
Exemplo n.º 2
0
 public Card(string rank, string suit) :
     this(Card.RankFromString(rank), Card.SuitFromString(suit))
 {
 }