Esempio n. 1
0
 public static bool DoesCardMatch(Card cardToCheck, Values value)
 {
     if (cardToCheck.Value == value)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 2
0
 public static bool DoesCardMatch(Card cardToCheck, Suits suit)
 {
     if (cardToCheck.Suit == suit)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Card threeOfClubs = new Card(Suits.Clubs, Values.Three);
            using (Stream output = File.Create("three-c.dat"))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(output, threeOfClubs);
            }

            Card sixOfHearts = new Card(Suits.Hearts, Values.Six);
            using (Stream output = File.Create("six-h.dat"))
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(output, sixOfHearts);
            }

            byte[] firstFile = File.ReadAllBytes("three-c.dat");
            byte[] secondFile = File.ReadAllBytes("six-h.dat");
            for (int i = 0; i < firstFile.Length; i++)
                if (firstFile[i] != secondFile[i])
                    Console.WriteLine("Byte #{0}: {1} versus {2}",
                        i, firstFile[i], secondFile[i]);

            firstFile[307] = (byte)Suits.Spades;
            firstFile[364] = (byte)Values.King;
            File.Delete("king-s.dat");
            File.WriteAllBytes("king-s.dat", firstFile);

            using (Stream input = File.OpenRead("king-s.dat"))
            {
                BinaryFormatter bf = new BinaryFormatter();
                Card kingOfSpades = (Card)bf.Deserialize(input);
                Console.WriteLine(kingOfSpades);
            }

            Console.ReadKey();
        }
Esempio n. 4
0
 public void Add(Card cardToAdd)
 {
     cards.Add(cardToAdd);
 }