static void Main(string[] args) { Program p = new Program(); Console.WriteLine("Select Option:"); Console.WriteLine("2: Fibonacci"); Console.WriteLine("3: Factorial"); Console.WriteLine("4: Do these Circles intersect?"); Console.WriteLine("5: Deck Shuffle"); Console.WriteLine("6: Fizz-Buzz"); string input = Console.ReadLine(); int r = 0; string result = ""; string er = "Invalid..Not a number"; if (!input.IsNumber(ref r)) { Console.WriteLine(er); return; } switch (r) { case 2: Console.WriteLine("Enter a number to Calculate Fibonacci"); input = Console.ReadLine(); if (!input.IsNumber(ref r)) { return; } fabo = new int[r+1]; result = p.Fibonacci(r).ToString(); break; case 3: Console.WriteLine("Enter a number to Calculate Factorial"); input = Console.ReadLine(); if (!input.IsNumber(ref r)) return; result = p.Factorial(r).ToString(); break; case 4: Console.WriteLine("Enter a number to Calculate Factorial"); input = Console.ReadLine(); if (!input.IsNumber(ref r)) return; Circle c1 = new Circle(0, 1, 1); Circle c2 = new Circle(2, 0, 2); result = p.DoCirclesIntersect(c1, c2).ToString(); break; case 5: Deck deck = new Deck(); List<Card> cards = deck.getDeck(); cards = deck.Shuffle(cards); foreach (Card c in cards) { Console.WriteLine(c.Color + "_" + c.Suit + "_" + c.Text); } break; case 6: var list = p.FizzBuzz(); foreach (string s in list) { Console.WriteLine(s); } break; default: result = "Invalid Input"; break; } Console.WriteLine(result); Console.ReadLine(); }
public bool DoCirclesIntersect(Circle c1, Circle c2) { double distance = Math.Sqrt(Math.Pow((c1.x - c2.x), 2) + Math.Pow((c1.y - c2.y), 2)); double sumOfRadii = c1.radius + c2.radius; return distance - sumOfRadii < 0; }