Exemple #1
0
        ///
        /// <param name="noOfInheritanceChains"> : User defined desired number of inheritance chains </param>
        /// <param name="inheritanceDepth"> : Maximum allowed inheritance depth </param>
        /// <param name="range">: Total number of classes </param>
        /// <returns> Something like this: {<3,5,1>,<7,2,6>} random but unique list of integers  </returns>
        public static List <List <int?> > getInheritanceList(int noOfInheritanceChains, int inheritanceDepth, int range) // number of classes
        {
            //Ishtiaque: this is probably already checked
            //Bala: This is a static method which can be reused for Interfaces
            //Even if the main stub is replaced with a GUI, this check will be needed.
            if (range < (noOfInheritanceChains * inheritanceDepth))
            {
                Console.WriteLine("getInheritanceList:: Invalid range");
                return(null);
            }
            List <List <int?> > inheritanceList = new List <List <int?> >();

            List <int?> usedList = new List <int?>();

            for (int i = 0; i < noOfInheritanceChains; i++)
            {
                Random random = new Random();

                //we don't want a 0 depth inheritance chain.
                int randomizedInheritanceDepth = random.Next(inheritanceDepth) + 1;

                // considering MinInheritanceDepth;  Min. InheritanceDepth should be less than equal to Max.,=> this is checked in GUI
                if (randomizedInheritanceDepth < minInheritanceDepth)
                {
                    randomizedInheritanceDepth = minInheritanceDepth;
                }



                inheritanceList.Add(ProgGenUtil.getRandomList(randomizedInheritanceDepth, range, usedList));
            }
            return(inheritanceList);
        }