static void Main()
        {
            var section = InterfaceFunctions.ChooseSection <StructuresSections>();

            switch (section)
            {
            case StructuresSections.ICollection:
            case StructuresSections.IList:
            case StructuresSections.ISet:
            case StructuresSections.IDictionary:
            {
                ICollectionTest.MethodsOfICollection(section);
            }
            break;

            case StructuresSections.ITest:
            {
                IList <string> testList = new MyList <string>();
                testList.Add("Luka");
                testList.Add("Jernej");
                testList.Add("Borut");
                Console.WriteLine($"Imamo {testList.Count} elementov!");
            }
            break;

            case StructuresSections.TestSpeed:
            {
                TestSpeed.TestDataStructures(InterfaceFunctions.ChooseSection <TestAction>());
            }
            break;

            case StructuresSections.HanoiExample:
            {
                Console.WriteLine("Hanoi example ");
                HanoiType type = Hanoi.SelectHanoiType();

                Console.Write("Enter number of discs: ");
                int k = int.Parse(Console.ReadLine());

                Console.WriteLine($"Running case: {type} with {k} discs:");

                int numPegs = 4;         // Delali bomo samo s štirimi stolpi

                Stopwatch sw       = Stopwatch.StartNew();
                Hanoi     hanBasic = new Hanoi(k, numPegs, type);
                int       length   = hanBasic.ShortestPathForSmallDimension(out _);

                Console.WriteLine();
                Console.WriteLine($"\n\nDimension: {k}; Steps: {length}; Time: {sw.Elapsed.TotalSeconds}");
                Console.WriteLine();
            }
            break;
            }

            Console.WriteLine();
            Console.WriteLine("Končano");
            Console.ReadLine();
        }
        public int HanoiTowerFactoryGet(int numDiscs, int numPegs, HanoiType type)
        {
            HanoiTypeModel factory = null;

            switch (type)
            {
            case HanoiType.K13_01:
            {
                factory = new HanoiTypeK13_01Model(numDiscs, numPegs, type);
            }

            break;

            case HanoiType.K13_12:
            {
                factory = new HanoiTypeK13_12Model(numDiscs, numPegs, type);
            }
            break;

            case HanoiType.K13e_01:
            case HanoiType.K13e_12:
            case HanoiType.K13e_23:
            case HanoiType.K13e_30:
            {
                factory = new HanoiTypeK13eModel(numDiscs, numPegs, type);
            }
            break;

            case HanoiType.K4e_01:
            case HanoiType.K4e_12:
            case HanoiType.K4e_23:
            {
                factory = new HanoiTypeK4eModel(numDiscs, numPegs, type);
            }
            break;

            case HanoiType.C4_01:
            case HanoiType.C4_12:
            {
                factory = new HanoiTypeC4Model(numDiscs, numPegs, type);
            }
            break;

            case HanoiType.P4_01:
            case HanoiType.P4_12:
            case HanoiType.P4_23:
            case HanoiType.P4_31:
            {
                factory = new HanoiTypeP4Model(numDiscs, numPegs, type);
            }
            break;
            }
            var length = factory.ShortestPathForSmallDimension(0, out _);

            return(length);
        }
Exemple #3
0
 private void InitIgnoredStates(HanoiType type)
 {
     switch (type)
     {
     case HanoiType.K13_01:
         AddStateLeading3();
         AddStateLeading1Then3();
         break;
     }
 }
        static void Main(string[] args)
        {
            Section section = Section.ITest;

            Console.WriteLine();
            switch (section)
            {
            case Section.ICollection:
            case Section.IList:
            case Section.ISet:
            case Section.IDictionary:
            {
                ICollectionTest.MethodsOfICollection(section);
            }
            break;

            case Section.ITest:
            {
                IList <string> testList = new MyList <string>();
                testList.Add("Luka");
                testList.Add("Jernej");
                testList.Add("Borut");
                Console.WriteLine($"Imamo {testList.Count} elementov!");
            }
            break;

            case Section.TestSpeed:
            {
                TestAction action = TestAction.Find;

                TestSpeed.NUMBERS_UP_TO = 101;
                TestSpeed.TestDataStructures(action);
                Console.WriteLine();

                TestSpeed.NUMBERS_UP_TO = 1001;
                TestSpeed.TestDataStructures(action);
                Console.WriteLine();

                TestSpeed.NUMBERS_UP_TO = 10001;
                TestSpeed.TestDataStructures(action);
            }
            break;

            case Section.HanoiExample:
            {
                Console.WriteLine("Hanoi example ");
                HanoiType type = Hanoi.SelectHanoiType();

                Console.Write("Enter number of discs: ");
                int k = int.Parse(Console.ReadLine());

                Console.WriteLine($"Running case: {type} with {k} discs:");

                int numPegs = 4;         // Delali bodo samo s štirimi stolpi

                Hanoi hanBasic = new Hanoi(k, numPegs, type);
                int   length   = hanBasic.ShortestPathForSmallDimension(0, out _);

                Console.WriteLine();
                Console.WriteLine("\n\nDimension: " + k + "; Steps: " + length);
                Console.WriteLine();
            }
            break;
            }

            Console.WriteLine();
            Console.WriteLine("Končano");
            Console.ReadLine();
        }
 public HanoiTypeK4eModel(int numDiscs, int numPegs, HanoiType type) : base(numDiscs, numPegs, type)
 {
     this.numDiscs = numDiscs;
     this.numPegs  = numPegs;
     this.type     = type;
 }
Exemple #6
0
 public Hanoi(int numDiscs, int numPegs, HanoiType type)
 {
     this.numDiscs = numDiscs;
     this.numPegs  = numPegs;
     this.type     = type;
 }
Exemple #7
0
        static void Main(string[] args)
        {
            // Uporabnik izbere tip hanoiskega stolpa, ki ga shranimo v spremnljivko
            Console.WriteLine("Hanoi example ");
            HanoiType type = HanoiTypeModel.SelectHanoiType();

            // Uporabnik napiše število diskov, ki jih parsamo v int
            Console.Write("Enter number of discs: ");
            int k = int.Parse(Console.ReadLine());

            Console.WriteLine($"Running case: {type} with {k} discs:");

            // Delali bodo samo s štirimi stolpi
            int numPegs = 4;
            // Prikaz izvajanja časa programa
            Stopwatch sw = Stopwatch.StartNew();
            // Ustvarimo novi objekt tipa Hanoi, kateremu podamo prej določene spremnljivke
            //HanoiTowerSelection hanBasic = new HanoiTowerSelection(k, numPegs, type);
            // Na našem objektu kličemo funkcijo za določanje najkrajše poti
            // HanoiTowerFactory factory = null;
            HanoiTowerFactory factory2 = new HanoiTowerFactory();
            int length = factory2.HanoiTowerFactoryGet(k, numPegs, type);

            //type.HanoiTowerFactory();

            /* switch (type)
             * {
             *   case HanoiType.K13_01:
             *       {
             *           factory = new HanoiTypeK13_01(k, numPegs, type);
             *       }
             *
             *       break;
             *   case HanoiType.K13_12:
             *       {
             *           factory = new HanoiTypeK13_12(k, numPegs, type);
             *       }
             *       break;
             *
             *   case HanoiType.K13e_01:
             *   case HanoiType.K13e_12:
             *   case HanoiType.K13e_23:
             *   case HanoiType.K13e_30:
             *       {
             *           factory = new HanoiTypeK13e(k, numPegs, type);
             *       }
             *       break;
             *   case HanoiType.K4e_01:
             *   case HanoiType.K4e_12:
             *   case HanoiType.K4e_23:
             *       {
             *           factory = new HanoiTypeK4e(k, numPegs, type);
             *       }
             *       break;
             *   case HanoiType.C4_01:
             *   case HanoiType.C4_12:
             *       {
             *           factory = new HanoiTypeC4(k, numPegs, type);
             *       }
             *       break;
             *   case HanoiType.P4_01:
             *   case HanoiType.P4_12:
             *   case HanoiType.P4_23:
             *   case HanoiType.P4_31:
             *       {
             *           factory = new HanoiTypeP4(k, numPegs, type);
             *       }
             *       break;
             * }
             * //var length = factory.ProcessHanoiTowers(0, out _);*/

            Console.WriteLine();
            Console.WriteLine($"\n\nDimension: {k} ; Steps:  {length} ; Time {sw.Elapsed.TotalSeconds}");
            Console.WriteLine();

            Console.WriteLine();
            Console.WriteLine("Končano");
            Console.ReadLine();
        }