Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //This is the main Class from which every class objects are created
            Console.WriteLine("Enter 1 for UnOrderedList.\nEnter 2 for OrderedList " +
                              "\n" +
                              "Enter 3 for BalancedParantheses \n" +
                              "Enter 4 for CashCounter \n" +
                              "Enter 5 for PalidromeCheck \n" +
                              "Enter 6 for BinarySearchTree \n" +
                              "Enter 7 for HashFunction\n" +
                              "Enter 8 for PrimeNumber2Dimension \n" +
                              "Enter 9 for Anagrams in array\n" +
                              "Enter 10 for AnagranToStack\n" +
                              "Enter 11 for AnagranToQue\n" +
                              "Enter 12 for Calender");

            int number = int.Parse(Console.ReadLine());

            //by using a static method called DriverMethod to invoke the particular class
            switch (number)
            {
            case 0: new Test(); break;

            case 1: ReadFromFile.DriverMethod(); break;

            case 2: FileReader.DriverMethod(); break;

            case 3: BalancedParentheses.DriverMethod(); break;

            case 4: new CashCounter(); break;

            case 5: PalindromeChecker.DriverMethod(); break;

            case 6: BinarySearchTree.DriverMethod(); break;

            case 7: HashTable.DriverMethod(); break;

            case 8: PrimeNumber2Dimension.DriverMethod(); break;

            case 9: Anagram.DriverMethod(); break;

            case 10: AnagramToStack.DriverMethod(); break;

            case 11: AnagramToQue.DriverMethod(); break;

            case 12: Calender.DriverMethod(); break;

            default: Console.WriteLine("invalid Entry");; break;
            }
        }
        public static void DriverMethod()
        {
            Anagram        a  = new Anagram();
            AnagramToStack ra = new AnagramToStack();

            List <int>  prime_list   = a.PrimeRange(0, 1000);
            List <int>  Anagram_list = a.PrimeAnagram(prime_list);
            Stack <int> s            = new Stack <int>(Anagram_list.Size());

            //storing anagrams form list to stack
            for (int i = 0; i < Anagram_list.Size(); i++)
            {
                s.Push(Anagram_list.peek(i));
            }
            Console.WriteLine("Anagrams stored in Stack are: ");
            Console.WriteLine(s);
            //
            Console.WriteLine("displaying Anagreams Reverse : ");
            while (!s.IsEmpty())
            {
                Console.Write(ra.Reverse(s.Pop()) + " ");
            }
        }