Esempio n. 1
0
        public List <PinModel> GeneratePin(int param_num)
        {
            int             temp = 0; bool isFibo = false; int random = 0;
            List <PinModel> models    = null;
            IFibonacciCheck fiboCheck = null;

            try
            {
                models    = new List <PinModel>();
                fiboCheck = new FibonacciCheck();

                for (int index = 0; index < param_num; index++)
                {
                    random = Util.GetRandomNumber(0, 9999);
                    temp   = random;

                    if (models.Count >= 0)
                    {
                        var result = models.Where(o => o.RandomNumber == temp).Any();
                        if (index == param_num - 1)
                        {
                            isFibo = models.Where(o => o.IsFibonacci == true).Any();
                            if (!isFibo)
                            {
                                random = fiboCheck.Fibonacci(Util.GetRandomNumber(1, 21));
                            }
                        }
                        if (result)
                        {
                            index--; continue;
                        }
                        else
                        {
                            var value = fiboCheck.IsFibonacci(random);
                            models.Add(new PinModel {
                                RandomNumber = random, IsFibonacci = value
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(models);
        }
Esempio n. 2
0
        public void Close()
        {
            if (_obj != null)
            {
                _obj = null;
            }

            if (randomobj != null)
            {
                randomobj = null;
            }

            if (fiboCheck != null)
            {
                fiboCheck = null;
            }
        }
Esempio n. 3
0
 public void Init()
 {
     _obj      = new ProgrammingTest.ProgrammingTest();
     randomobj = new RandomPinGenerator();
     fiboCheck = new FibonacciCheck();
 }