Beispiel #1
0
 public FlipPwdCheck(PwdCheck obj, string pd) : base(pd)
 {
     pObj = obj;
     obj  = null;
 }
Beispiel #2
0
        //Pre : Constant array size must be declared and assigned
        //Post: Return a new Flip Heterogenous Array
        //      Objects in HG array contains Flip & FlipPwdCheck (PwdCheck, ExcessC & CompundC)
        //      ExcessC object state is initial set to false
        public static Flip[] InitFlipHeterogeneousArray(Random rand)
        {
            Console.WriteLine("");
            Console.WriteLine(ASTERISK + "BEGIN INITIALIZE FLIP HETEROGENOUS ARRAY" + ASTERISK);
            Console.WriteLine("Initialize " + (A_SIZE / QUARTER) + " FLIP & " + (A_SIZE - A_SIZE / QUARTER) + " FLIPPWDCHECK OBJECTS");

            Flip[]   flipObj = new Flip[A_SIZE];
            uint     randPwdLength;
            string   psdWord;
            PwdCheck pObj;
            CompundC cObj;
            ExcessC  eObj;


            for (int i = 0; i < A_SIZE; i++)
            {
                psdWord = GenerateRandomValidPassword(rand);

                if (i < QUARTER)
                {
                    Console.WriteLine("{0} object [{1}], password = {2}", ObjectName.FLIP, i, psdWord);
                    flipObj[i] = new Flip(psdWord);
                }
                else if (i >= QUARTER && i < QUARTER + QUARTER)
                {
                    if (i == QUARTER)
                    {
                        Console.WriteLine("");
                    }

                    randPwdLength = (uint)rand.Next(RAND_MIN, RAND_MAX);
                    pObj          = new PwdCheck(randPwdLength);
                    flipObj[i]    = new FlipPwdCheck(pObj, psdWord);
                    Console.WriteLine(" {0} object [{1}], password length = {2}, status = {3}", ObjectName.PwdClass, i, randPwdLength, pObj.GetObjectActive() ? "active" : "inactive");
                }
                else if (i >= QUARTER + QUARTER && i < A_SIZE - QUARTER)
                {
                    if (i == QUARTER + QUARTER)
                    {
                        Console.WriteLine("");
                    }

                    randPwdLength = (uint)rand.Next(RAND_MIN, RAND_MAX);
                    uint toggleCycle = (uint)rand.Next(RAND_MIN, RAND_MAX);
                    cObj       = new CompundC(randPwdLength, toggleCycle);
                    flipObj[i] = new FlipPwdCheck(cObj, psdWord);
                    Console.WriteLine(" {0} object [{1}], password length = {2}, toggle cycle = {3}, toggle limit = {4}, status = {5} ", ObjectName.CompundC, i, randPwdLength, toggleCycle, toggleCycle * ONECYLE * randPwdLength, (cObj.GetObjectActive() ? "active" : "inactive"));
                }
                else
                {
                    if (i == A_SIZE - QUARTER)
                    {
                        Console.WriteLine("");
                    }
                    bool objStatus = false;
                    randPwdLength = (uint)rand.Next(RAND_MIN, RAND_MAX);
                    eObj          = new ExcessC(randPwdLength, objStatus);
                    flipObj[i]    = new FlipPwdCheck(eObj, psdWord);
                    Console.WriteLine(" {0} object[{1}], password length = {2}, status = {3} ", ObjectName.ExcessC, i, randPwdLength, (eObj.GetObjectActive() ? "active" : "inactive"));
                }
            }
            Console.WriteLine(ASTERISK + "END INITIALIZE FLIP HETEROGENOUS ARRAY" + ASTERISK);
            return(flipObj);
        }