public static String Analyze(int a, int b, int c) { TriangleSolver tr = new TriangleSolver(); if (tr.checkValidity(Convert.ToInt32(a), Convert.ToInt32(b), Convert.ToInt32(c))) { String triangleName = tr.whichTriangle(Convert.ToInt32(a), Convert.ToInt32(b), Convert.ToInt32(c)); return(triangleName); } else { return("Not form a triangle"); } }
public static void Main(string[] args) { char answer; do { Console.WriteLine(" Welcome to Triangle Solver Select a menu option to continue \n"); Console.WriteLine("1.Enter triangle dimension"); Console.WriteLine("2.Exit \n"); Console.WriteLine("Enter your menu choice \n"); TriangleSolver tri = new TriangleSolver(); var selection = Console.ReadLine(); if (isNumber(selection)) { String result = ""; if (Convert.ToInt32(selection) == 1 || Convert.ToInt32(selection) == 2) { switch (selection) { case "1": Console.WriteLine("Enter triangle dimension "); break; case "2": return; } TriangleSolver tro = new TriangleSolver(); Console.Write("Input side 1 of triangle: "); var a = Console.ReadLine(); Console.Write("Input side 2 of triangle: "); var b = Console.ReadLine(); Console.Write("Input side 3 of triangle: "); var c = Console.ReadLine(); if (isNumber(a) && isNumber(b) && isNumber(c)) { result = TriangleSolver.Analyze(Convert.ToInt32(a), Convert.ToInt32(b), Convert.ToInt32(c)); } Console.WriteLine(result); } else { Console.WriteLine("Enter valid menu option \n"); } } else { Console.WriteLine("Entered character is not a number"); } Console.ReadLine(); Console.WriteLine("Do you want to continue"); answer = Convert.ToChar(Console.ReadLine()); } while (answer == 'y' || answer == 'Y'); }