Advertisement
Guest User

Check for a Play Card

a guest
Apr 6th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. class CheckForPlayCard
  3. {
  4.     static void Main()
  5.     {
  6.         string card;
  7.  
  8.         do
  9.         {
  10.             Console.WriteLine("Enter card:");
  11.             card = Console.ReadLine();
  12.  
  13.             if (card.Length > 1)
  14.             {
  15.                 Console.WriteLine("Please, enter one symbol only.");
  16.             }
  17.  
  18.         } while (card.Length > 1);
  19.  
  20.         const string deck = "23456789JQKA";
  21.         double i = deck.IndexOf(card);
  22.         if (i == -1)
  23.         {
  24.             Console.WriteLine("no");
  25.         }
  26.         else
  27.         {
  28.             Console.WriteLine("yes");
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement