Beispiel #1
0
        /*
         * Generate card
         * Add card number to list of cards and funds, starting with no funds
         * Return the new card
         */
        public static Int32 registerCreditCard()
        {
            ServiceReference1.ServiceClient serviceClient = new ServiceReference1.ServiceClient();
            Random rnd = new Random();
            bool   valid;
            Int32  newCard;
            string encryptedCard = "";

            do
            {
                valid   = true;
                newCard = rnd.Next(5000, 10000);
                for (int i = 0; i < cardList.Count && valid; i++)
                {
                    if (newCard == Int32.Parse(serviceClient.Decrypt(cardList[i])))
                    {
                        valid = false;
                    }
                }
            } while (!valid);
            encryptedCard = serviceClient.Encrypt(newCard.ToString());
            cardList.Add(encryptedCard);
            fundsList.Add(0);
            return(newCard);
        }