コード例 #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;
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: nsmith4848/cis237inclass2
        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;
            }            
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: jsziede/cis237inclass2
 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;
     }
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: lmc22/Inclass2
        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;
            }
        }