您的位置:首页 > 其它

14.3 正则表达式应用

2010-04-18 20:30 225 查看
14.3.4 查找嵌套标记

代码

Sub PlayPoker()
PlayPokerHand("StraightFlush", "1H", "2H", "3H", "4H", "5H")
PlayPokerHand("StraightFlush", "3H", "4H", "5H", "6H", "7H")
PlayPokerHand("StraightFlush", "6C", "7C", "8C", "9C", "TC")
PlayPokerHand("StraightFlush", "7S", "8S", "9S", "TS", "JS")
PlayPokerHand("StraightFlush", "8S", "9S", "TS", "JS", "QS")
PlayPokerHand("StraightFlush", "TD", "JD", "QD", "KD", "1D")

PlayPokerHand("Flush", "8S", "JS", "QS", "KS", "1S")
PlayPokerHand("Flush", "7H", "8H", "9H", "TH", "KH")
PlayPokerHand("Flush", "8C", "9C", "TC", "QC", "KC")

PlayPokerHand("FourOfAKind", "8C", "9D", "8D", "8H", "8S")
PlayPokerHand("FourOfAKind", "TS", "TC", "QD", "TD", "TH")
PlayPokerHand("FourOfAKind", "1C", "1S", "8S", "1H", "1D")

PlayPokerHand("FullHouse", "1C", "1D", "8C", "1D", "8S")
PlayPokerHand("FullHouse", "9C", "9S", "8D", "8S", "9H")
PlayPokerHand("FullHouse", "QC", "TD", "QD", "TS", "QS")

PlayPokerHand("Straight", "3S", "7S", "5S", "4S", "6D")
PlayPokerHand("Straight", "6D", "7S", "8H", "9H", "TD")
PlayPokerHand("Straight", "7S", "8D", "9D", "TH", "JC")
PlayPokerHand("Straight", "TC", "JS", "QS", "KS", "1S")

PlayPokerHand("ThreeOfAKind", "9C", "9S", "8H", "TD", "9D")
PlayPokerHand("ThreeOfAKind", "TC", "TS", "7S", "TH", "1D")
PlayPokerHand("ThreeOfAKind", "TC", "TS", "8S", "TH", "KH")

PlayPokerHand("TwoPairs", "1C", "1F", "8F", "DP", "8Q")
PlayPokerHand("TwoPairs", "9C", "KF", "8F", "8P", "9Q")
PlayPokerHand("TwoPairs", "1C", "DF", "QF", "DP", "QQ")

PlayPokerHand("OnePair", "1C", "1H", "KH", "TS", "8S")
PlayPokerHand("OnePair", "9C", "KH", "QH", "8S", "9D")
PlayPokerHand("OnePair", "1S", "TS", "QC", "8C", "QC")

PlayPokerHand("HighCard", "1C", "QC", "KC", "TD", "8D")
PlayPokerHand("HighCard", "TC", "KC", "QD", "8D", "9H")
PlayPokerHand("HighCard", "1C", "TC", "KD", "8D", "QH")
PlayPokerHand("HighCard", "8D", "QD", "TD", "9D", "KH")
End Sub

Private Sub PlayPokerHand(ByVal expectedScore As String, ByVal ParamArray cards() As String)
Dim score As String = PokerGame.EvalPokerScore2(cards)
Console.WriteLine("{0} {1} {2} {3} {4} => {5}", cards(0), cards(1), cards(2), cards(3), cards(4), score)
If score <> expectedScore Then Console.WriteLine(" WRONG! (expected {0})", expectedScore)
End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: