Advertisement
kuruku

PrintDeckof52Cards

May 3rd, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2.  
  3. //Write a program that generates and prints all possible cards from a standard deck of 52 cards
  4. //(without the jokers). The cards should be printed using the classical notation (like 5♠, A♥, 9♣ and K♦).
  5. //The card faces should start from 2 to A. Print each card face in its four possible suits: clubs,
  6. //diamonds, hearts and spades. Use 2 nested for-loops and a switch-case statement.
  7.  
  8.     class PrintDeckof52Cards
  9.     {
  10.         static void Main()
  11.         {
  12.             for (int i = 2; i <= 14; i++)
  13.             {
  14.                 if (i == 11)
  15.                 {
  16.                     Console.WriteLine("{0,4} {1,4} {2,4} {3,4}", 'J' + "" + (char)5, 'J' + "" + (char)3, 'J' + "" + (char)4, 'J' + "" + (char)6);
  17.                 }
  18.                 if (i == 12)
  19.                 {
  20.                     Console.WriteLine("{0,4} {1,4} {2,4} {3,4}", 'Q' + "" + (char)5, 'Q' + "" + (char)3, 'Q' + "" + (char)4, 'Q' + "" + (char)6);
  21.  
  22.                 }
  23.                 if (i == 13)
  24.                 {
  25.                     Console.WriteLine("{0,4} {1,4} {2,4} {3,4}", 'K' + "" + (char)5, 'K' + "" + (char)3, 'K' + "" + (char)4, 'K' + "" + (char)6);
  26.  
  27.                 }
  28.                 if (i == 14)
  29.                 {
  30.                     Console.WriteLine("{0,4} {1,4} {2,4} {3,4}", 'A' + "" + (char)5, 'A' + "" + (char)3, 'A' + "" + (char)4, 'A' + "" + (char)6);
  31.  
  32.                 }
  33.                 if (i>=2 && i<=10)
  34.                 {
  35.                     Console.WriteLine("{0,4} {1,4} {2,4} {3,4}", i + "" + (char)5, i + "" + (char)3, i + "" + (char)4, i + "" + (char)6);
  36.                    
  37.                 }
  38.             }
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement