Beispiel #1
0
        /// <summary>
        /// Main. Selects either factorials or hanoi.
        /// </summary>
        /// <param name="args">Main-line args.</param>
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorials or 2 for Tower of Hanoi.");
            string userInput = Console.ReadLine().Trim();
            Console.WriteLine();

            switch (userInput)
            {
                case "1":
                    Factorial factorial = new Factorial();
                    break;
                case "2":
                    Console.WriteLine("Enter number of disks on tower. For best output, try 5 or lower.");
                    userInput = Console.ReadLine().Trim();
                    try
                    {
                        HanoiTower hanoi = new HanoiTower(Convert.ToInt32(userInput));
                    }
                    catch
                    {
                        Console.WriteLine("You must enter an int. Try '3'.");
                    }
                    break;
                default:
                    Console.WriteLine("Invalid input.");
                    break;
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Factorial factorial = new Factorial();

            Console.WriteLine("The answer to 5! is: ");
            Console.WriteLine(factorial.Calculate(5));
        }
        static void Main(string[] args)
        {
            Factorial factorial = new Factorial();

            Console.WriteLine("The answer to 5! is: " + factorial.Calculate(5));

            Console.WriteLine("--------------------------------------------------------");
            Console.WriteLine("");

            Hanoi hanoi = new Hanoi();

            hanoi.moveDisc(30, 'A', 'B', 'C');
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorial or 2 for Tower of Hanoi");
            string userInput = Console.ReadLine();

            if (userInput == "1")
            {
                //Do Factorial
                Factorial factorial = new Factorial();
            }
            else
            {
                //Do Tower of Hanoi
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorial or 2 for Tower of Hanoi");
            string userInput = Console.ReadLine();

            if (userInput == "1")
            {
                //The Dawn way!
                Factorial factroial = new Factorial();
            }
            else
            {
                //Do Tower of Hanoi
                //The Dawn way again
                TowerOfHanoi towerOfHanoi = new TowerOfHanoi();
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorial or 2 for Tower of Hanoi");
            string userInput = Console.ReadLine();

            if (userInput == "1")
            {
                //The Dawn way(work done in constructor)
                Factorial factorial = new Factorial();
            }
            else
            {
                //DO towers of Hanoi
                //The Dawn way(work done in constructor)
                TowerOfHanoi towerOfHanoi = new TowerOfHanoi();
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorial or 2 for Towers of Hanoi");
            string userInput = Console.ReadLine();

            if (userInput == "1")
            {//Do Factorial
                //The Dawn way
                Factorial factorial = new Factorial();
            }
            else
            {
                //Do Towers of Hanoi
                //The Dawn Way Again!!!
                TowersOfHanoi tower = new TowersOfHanoi();
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorial or 2 for Tower of Hanoi");
            string userInput = Console.ReadLine();

            if (userInput == "1")
            {
                Factorial factorial = new Factorial();
            }
            else if (userInput == "2")
            {
                TowerOfHanoi towerOfHanoi = new TowerOfHanoi();
            }
            else
            {
                //Throw error
            }
        }