public static void DoChallenge1A() { do { Console.WriteLine("1.A: Enter values for Row (A-F upper or lower case) and Column (1-12 no decimals)"); Console.WriteLine("Enter a letter for the Row:"); string myRowInput = Console.ReadLine().ToUpper(); Console.WriteLine("Enter a number for the Column:"); string myColumnInput = Console.ReadLine().ToUpper(); string myError = null; try { var myTuple = MyTriangle.GetRowAndColumnNumbersFromInput(myRowInput, myColumnInput, out myError); if (myError == null) { if (myTuple != null) { int myRowNumber = myTuple.Item1; int myColumnNumber = myTuple.Item2; string myLabel = MyTriangle.GetCoordinatesFromRowAndColumn(myRowNumber, myColumnNumber, out myError); if (myError == null) { Console.WriteLine("The coordinates for Triangle " + myRowInput + myColumnInput + " are: " + myLabel); } } } else { Console.WriteLine("Error: " + myError); } } catch (Exception ex) { myError = "Exception thrown: " + ex.Message; } finally { if (myError != null) { Console.WriteLine("Error: " + myError); } } Console.WriteLine("Press A to enter another row and column, or any other key to exit to main menu."); }while (Console.ReadLine().ToUpper().StartsWith("A")); }
public static void DoChallenge1B() { do { Console.WriteLine("1.B: Triangle coordinates can be entered in any order. \nAll must be multiples of 10 from 0 to 60, separted by a comma. e.g. 10,20"); Console.WriteLine("Enter X-Y coordinates for first vertex:"); string myXY0 = Console.ReadLine(); Console.WriteLine("Enter X-Y coordinates for second vertex:"); string myXY1 = Console.ReadLine(); Console.WriteLine("Enter X-Y coordinates for third vertex:"); string myXY2 = Console.ReadLine(); string myError = null; try { List <Tuple <int, int> > myCorners = MyTriangle.GetCornersFromInput(new List <string> { myXY0, myXY1, myXY2 }, out myError); if (myError == null) { if (myCorners != null) { MyTriangle myTest = new MyTriangle(myCorners); if (myTest.HasValidCorners(out myError)) { Console.WriteLine("The label for triangle bounded by " + myTest.MyCorners + " is: " + myTest.GetTriangleName()); } else { Console.WriteLine("Error: " + myError); } } } else { Console.WriteLine("Error: " + myError); } } catch (Exception ex) { Console.WriteLine("Exception thrown: " + ex.Message); } Console.WriteLine("Press B to enter another set of vertices, or any other key to exit to main menu."); }while (Console.ReadLine().ToUpper().StartsWith("B")); }