Ejemplo n.º 1
0
        public static void NewUser(List <Costumer> costumerList)
        {
            Console.WriteLine("Enter Your name");
            string name          = Console.ReadLine();
            Random rnd           = new Random();
            int    cardNumber1   = rnd.Next(10000000, 99999999);
            int    cardNumber2   = rnd.Next(10000000, 99999999);
            string cardNumberSTR = String.Concat(cardNumber1, cardNumber2);
            int    pin           = rnd.Next(1000, 9999);

            if (long.TryParse(cardNumberSTR, out long cardNumber))
            {
                for (int i = 0; i < costumerList.Count; i++)
                {
                    if (cardNumber == costumerList[i].CardNum)
                    {
                        Console.WriteLine("Try again");
                        return;
                    }
                }

                Costumer user1 = new Costumer(name, cardNumber);
                user1.AddPin(pin);
                user1.AddBalance();
                Console.WriteLine($"Your card number is:{cardNumber} your pin is {pin}");
                costumerList.Add(user1);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Costumer aleksandar = new Costumer("Aleksandar", 1234123412341234);
            Costumer pero       = new Costumer("Pero", 9876987698769876);
            Costumer maja       = new Costumer("Maja", 4444333322221111);
            Costumer ljupco     = new Costumer("Ljupco", 8888888888888888);

            aleksandar.AddPin(1234);
            pero.AddPin(9876);
            maja.AddPin(1111);
            ljupco.AddPin(5555);

            aleksandar.AddBalance();
            pero.AddBalance();
            maja.AddBalance();
            ljupco.AddBalance();

            List <Costumer> costumerList = new List <Costumer> {
                aleksandar, pero, maja, ljupco
            };


            Console.WriteLine("If you want to create new user enter 'N' if not press any other key");
            string newUser = Console.ReadLine();

            if (newUser.ToLower() == "n")
            {
                NewUser(costumerList);
                Costumer[] costumerArr = costumerList.ToArray();
                Login(costumerArr);
            }
            else
            {
                Costumer[] costumerArr = costumerList.ToArray();
                Login(costumerArr);
            }
        }