Rank.parse constructor
Rank.parse(
- String value
Parses a char (1-charactor-length string) and returns a Rank. The value must be one of "A"
, "2"
, "3"
, "4"
, "5"
, "6"
, "7"
, "8"
, "9"
, "T"
, "J"
, "Q"
or "K"
.
assert(Rank.parse("A") == Rank.ace);
assert(Rank.parse("8") == Rank.eight);
If any string else is given, this throws a RankParseFailureException.
Rank.parse("a"); // throws RankParseFailureException
Rank.parse("eight"); // throws RankParseFailureException
Implementation
factory Rank.parse(String value) {
switch (value) {
case 'A':
return Rank.ace;
case '2':
return Rank.deuce;
case '3':
return Rank.trey;
case '4':
return Rank.four;
case '5':
return Rank.five;
case '6':
return Rank.six;
case '7':
return Rank.seven;
case '8':
return Rank.eight;
case '9':
return Rank.nine;
case 'T':
return Rank.ten;
case 'J':
return Rank.jack;
case 'Q':
return Rank.queen;
case 'K':
return Rank.king;
default:
throw RankParseFailureException(value);
}
}