}// end of playCards_Test static private void playCards_V1() { try { PlayingCard player1 = new PlayingCard("Red", CardSuit.Clubs); Console.WriteLine("Player 1 1 drew " + player1.ToString()); PlayingCard player2 = new PlayingCard("Red", CardSuit.Clubs); Console.WriteLine("Player 3 1 drew " + player1.ToString()); Console.WriteLine(FindWinner(player1, player2)); } catch (Exception e) { Console.WriteLine("Error " + e.Message); } }
private static string FindWinner(PlayingCard p1, PlayingCard p2) { string result = ""; if (p1.Num > p2.Num) { result = String.Format("Player 1 won as {0} is worth more than {1}", p1.Num, p2.Num); } else if (p1.Num < p2.Num) { result = String.Format("Player 1 won as {0} is worth more than {1}", p1.Num, p2.Num); } else { result = String.Format("Draw as {0} matched {1}", p1.Num, p2.Num); } }
}// end of playGame2_TenSided static private void playCards_Test() { try { Console.WriteLine("Playing Card game one"); PlayingCard player1; player1 = new PlayingCard(1, "Red", CardSuit.Clubs, CardName.King); Console.WriteLine("What is this? \n" + player1.ToString() + "\n"); player1 = new PlayingCard(1, "Red", CardSuit.Clubs); Console.WriteLine("What is this? \n" + player1.ToString() + "\n"); player1 = new PlayingCard(1, "Red", CardSuit.Clubs); Console.WriteLine("What is this? \n" + player1.ToString() + "\n"); } catch (Exception e) { Console.WriteLine("Error " + e.Message); } }// end of playCards_Test