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(); }
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; } }
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; } }
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; } }