Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorials or 2 for Tower of Hanoi");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
                case "1":
                    Factorial factorial = new Factorial();
                    break;
                case "2":
                    Console.WriteLine("Enter number of disks on tower. Try 5 or lower.");
                    userInput = Console.ReadLine();
                    try
                    {
                        // Create a new instance of the Hanoi class
                        Hanoi hanoi = new Hanoi();

                        // Call the moveDisk method to start solving the problem.
                        hanoi.moveDisk("|", Int32.Parse(userInput), 'A', 'B', 'C');
                    } catch
                    {
                        Console.WriteLine("You must enter an int");
                    }
                    break;
                default:
                    Console.WriteLine("Invalid input");
                    break;
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for facorial or 2 for Towers of Hanoi");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
                case "1":
                    Factorial factorial = new Factorial();
                    break;
                case "2":
                    
                    Console.WriteLine("Enter number of disks on tower. Try 5 or lower.");
                    userInput = Console.ReadLine();
                    try
                    {
                        Hanoi hanoi = new Hanoi();

                        hanoi.MoveDisk(int.Parse(userInput), 'A', 'B', 'C');
                    }
                    catch
                    {
                        Console.WriteLine("You must enter an integer");
                    }
                    break;

                default:
                    Console.WriteLine("Invalid input.");
                    break;
            }

            Console.ReadLine();
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorials or 2 for Tower of Hanoi.");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
                case "1" :
                    Factorial factorial = new Factorial();
                    break;

                case "2" :
                    Console.WriteLine("Enter number of disks on tower.  Try 5 or lower");
                    userInput = Console.ReadLine();
                    try
                    {
                        //DO Hanoi here
                        Hanoi hanoi = new Hanoi();
                        hanoi.MoveDisk(Convert.ToInt32(userInput), 'A', 'B', 'C');                        
                    }
                    catch
                    {
                        Console.WriteLine("You must Enter an int");
                    }

                    break;

                default:
                    Console.WriteLine("Invalid input");
                    break;
            }            
        }
Example #4
0
 static void Main(string[] args)
 {
     Console.WriteLine("Enter 1 for factorials or 2 for Tower of Hanoi.");
     string userInput = Console.ReadLine();
     switch(userInput)
     {
         case "1":
             Factorial factorial = new Factorial();
             break;
         case "2":
             Console.WriteLine("Enter number of disks on tower:");
             userInput = Console.ReadLine();
             try
             {
                 Hanoi hanoi = new Hanoi();
                 hanoi.moveDisks(Int32.Parse(userInput), 'A', 'B', 'C');
             }
             catch
             {
                 Console.WriteLine("Please use an integer.");
             }
             break;
         default:
             Console.WriteLine("Invalid entry.");
             break;
     }
 }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome! \n Please enter the program you would like to use:" +
                                "\n 1. for Factorials"+
                                "\n 2. for Towers of Hanoi");
            String userInput = Console.ReadLine();

            switch (userInput)
            {
                case "1" :
                    Factoria factorial = new Factoria();
                    break;

                case "2" :
                    Console.WriteLine("Enter the number of disks \n 'Hint: enter 5 or lower'");
                    userInput = Console.ReadLine();
                    try
                    {
                        //Do Hanoi Here
                        // Create a new instance of the hanoi class
                        Hanoi hanoi = new Hanoi();

                        //call the moveDisk metod to start solving the problems
                        hanoi.moveDisk(Int32.Parse(userInput), 'A', 'B', 'C');
                    }
                    catch
                    {
                        Console.WriteLine("You must enter an int");
                    }
                    break;

                default:
                    Console.WriteLine("Invalid Input ya tart! \n :(");
                    break;
            }
            
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter 1 for factorials or 2 for Tower of Hanoi");

            string userInput = Console.ReadLine();

            switch (userInput)
            {
            case "1":
            {
                Factorial factorial = new Factorial();
                break;
            }

            case "2":
            {
                Console.WriteLine("Enter number of disks on tower. Try 5 or lower");
                userInput = Console.ReadLine();
                try
                {
                    //Create a new instance of the Hanoi class
                    Hanoi hanoi = new Hanoi();
                    hanoi.moveDisk(Int32.Parse(userInput), 'A', 'B', 'C');
                }
                catch
                {
                    Console.WriteLine("You must enter an int");
                }
                break;
            }

            default:
                Console.WriteLine("Invalid input");
                break;
            }
        }