Debugging Functions
Debugging Functions
Debugging a Function
Introduction
We already know that a function is a section of code that solves one particular problem, and a function has a body delimited by curly brackets. These two characteristics provides some features to a function when it comes to debugging.
Practical Learning: Introducing Function Debugging
| SAS | ASA |
![]() |
![]() |
| Known Values: 2 sides and the 1 angle between them Unknown Values: 2 angles and the 1 sides between them |
Known Values: 2 angles and the 1 side joining them Unknown Values: 2 sides and the 1 angle between them |
| AAS | SSS |
![]() |
![]() |
| Known Values: 2 angles and the 1 side opposite the first angle Unknown Values: 2 sides and the 1 angle oppiste the second side |
Known Values: All 3 sides Unknown Values: All 3 angles |
using static System.Console; void CalculateAAS() { double angle1 = 0.00; double angle2 = 0.00; double side1 = 0.00; WriteLine("AAS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: Known Values: 2 sides and the 1 angle between them"); WriteLine("Sought Values: 2 angles and the 1 sides between them"); WriteLine("----------------------------------------------------------------------"); try { Write("AAS Angle 1: "); angle1 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the lower left angle of the AAS shape."); } try { Write("AAS Angle 2: "); angle2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the lower right angle of the AAS shape."); } try { Write("AAS Side 1: "); side1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for the right side of the AAS shape."); } // Here, we use the law of sines double angle3 = 180 - (angle1 + angle2); double side2 = side1 * Math.Sin(angle2 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); double side3 = side1 * Math.Sin(angle3 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("AAS Angle 3: " + angle3.ToString()); WriteLine("AAS Side 2: " + side2.ToString()); WriteLine("AAS Side 3: " + side3.ToString()); } void CalculateASA() { double angle1 = 0.00; double angle2 = 0.00; double side1 = 0.00; WriteLine("ASA Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: 2 angles and the 1 side joining them"); WriteLine("Sought Values: 2 sides and the 1 angle between them"); WriteLine("----------------------------------------------------------------------"); try { Write("ASA Angle 1: "); angle1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for one of the known angles of the ASA shape."); } try { Write("ASA Side 1: "); side1 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the side that is between the angles whose values are about the ASA shape."); } try { Write("AAS Angle 2: "); angle2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the other known angle of the ASA oblique triangle."); } // Here, we use the law of sines double angle3 = 180 - (angle1 + angle2); double side2 = side1 * Math.Sin(angle2 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); double side3 = side1 * Math.Sin(angle3 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("ASA Angle 3: {0}", angle3); WriteLine("ASA Side 2: {0}", side3); WriteLine("ASA Side 3: {0}", side2); } void CalculateSAS() { WriteLine("SAS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: 2 sides and 1 angle"); WriteLine("Sought Values: 1 unknown side and 2 unknown angles"); WriteLine("----------------------------------------------------------------------"); double side1 = 0.00; double angle1 = 0.00; double side2 = 0.00; WriteLine("Type the known values"); try { Write("SAS Side 1: "); side1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for one of the known sides of the SAS shape."); } try { Write("SAS Angle 1: "); angle1 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the known angle of the SAS shape."); } try { Write("SAS Side 2: "); side2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the other known side of the SAS shape."); } // Here, we use the law of cosines double side3 = Math.Sqrt((side1 * side1) + (side2 * side2) - (2 * side1 * side2 * Math.Cos(angle1 * Math.PI / 180))); double angle2 = Math.Acos(((side3 * side3) + (side2 * side2) - (side1 * side1)) / (2 * side3 * side2)) * 180 / Math.PI; double angle3 = 180 - (angle1 + angle2); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("SAS Side 3: {0}", side3.ToString()); WriteLine("SAS Angle 2: {0}", angle2.ToString()); WriteLine("SAS Angle 3: {0}", angle3.ToString()); } void CalculateSSS() { WriteLine("SSS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: All 3 sides"); WriteLine("Sought Values: All 3 angles"); WriteLine("----------------------------------------------------------------------"); double side1 = 0.00; double side2 = 0.00; double side3 = 0.00; WriteLine("Type the known values"); try { Write("SSS Side 1: "); side1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for one of the known sides of the SSS shape."); } try { Write("SSS Side 2: "); side2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for another side of the SSS triangle."); } try { Write("SSS Side 3: "); side3 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the remaining known side of the SSS oblique triangle."); } // Here, we use the law of cosines double angle1 = Math.Acos(((side3 * side3) + (side2 * side2) - (side1 * side1)) / (2 * side3 * side2)) * 180 / Math.PI; double angle2 = Math.Acos(((side3 * side3) + (side1 * side1) - (side2 * side2)) / (2 * side3 * side1)) * 180 / Math.PI; double angle3 = 180 - (angle1 + angle2); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine($"SSS Angle 1: {angle1}"); WriteLine($"SSS Angle 2: {angle2}"); WriteLine($"SSS Angle 3: {angle3}"); } WriteLine("======================================================================"); WriteLine("This application allows you to make calculations on oblique triangles"); WriteLine("======================================================================"); Title = "Oblique Triangles"; WriteLine("Available shape options:"); WriteLine("1 - AAS (Known: Angle - Angle - Side)"); WriteLine("2 - ASA (Known: Angle - Side - Angle)"); WriteLine("3 - SAS (Known: Side - Angle - Side)"); WriteLine("4 - SSS (Known: Side - Side - Side)"); WriteLine("Q - Quit"); Write("What type of triangle do you want to process? "); string selection = ReadLine()!; switch (selection) { case null: break; case "4": CalculateSSS(); break; case "3": CalculateSAS(); break; default: break; case "1": CalculateAAS(); break; case "2": CalculateASA(); break; } WriteLine("======================================================================");
So far, that is in previous lessons, we saw various ways to monitor the variables of a document and their values. All the techniques we studied are also available for variables declared and/or used in a function. It should be a good idea to review the issues.
Practical Learning: Introducing Function Debugging
Debugging the Variables of a Function
In previous lessons, we saw that the Step Into operation monitors the variables in a document. We also saw that the Locals window shows all the variables declared in a document. When it comes to a function, when debugging a function, the Locals window allows you to monitor all the variables declared in the function that is currently receiving the debugging operation.
Practical Learning: Debugging the Variables of a Function
====================================================================== This application allows you to make calculations on oblique triangles ====================================================================== Available shape options: 1 - AAS (Known: Angle - Angle - Side) 2 - ASA (Known: Angle - Side - Angle) 3 - SAS (Known: Side - Angle - Side) 4 - SSS (Known: Side - Side - Side) Q - Quit What type of triangle do you want to process? 4 SSS Shape ---------------------------------------------------------------------- Known Values: All 3 sides Sought Values: All 3 angles ---------------------------------------------------------------------- Type the known values SSS Side 1: 4.5 SSS Side 2: 3.5 SSS Side 3: 2.9 ====================================================================== Results ---------------------------------------------------------------------- SSS Angle 1: 88.84271591186852 SSS Angle 2: 51.043098746872104 SSS Angle 3: 40.11418534125937 ====================================================================== Press any key to close this window . . .
====================================================================== This application allows you to make calculations on oblique triangles ====================================================================== Available shape options: 1 - AAS (Known: Angle - Angle - Side) 2 - ASA (Known: Angle - Side - Angle) 3 - SAS (Known: Side - Angle - Side) 4 - SSS (Known: Side - Side - Side) Q - Quit What type of triangle do you want to process? 1 AAS Shape ---------------------------------------------------------------------- Known Values: Known Values: 2 sides and the 1 angle between them Sought Values: 2 angles and the 1 sides between them ---------------------------------------------------------------------- AAS Angle 1: 80 AAS Angle 2: 75 AAS Side 1: 14 ====================================================================== Results ---------------------------------------------------------------------- AAS Angle 3: 25 AAS Side 2: 13.731575047703062 AAS Side 3: 6.0079296149656205 ====================================================================== Press any key to close this window . . .
using static System.Console; double GetSASAngle1() { double angle = 0; try { Write("SAS Angle 1: "); angle = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the known angle of the SAS shape."); } return angle; } double GetSASSide1() { double side = 0; try { Write("SAS Side 1: "); side = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for one of the known sides of the SAS shape."); } return side; } double GetSASSide2() { double side = 0; try { Write("SAS Side 2: "); side = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the other known side of the SAS shape."); } return side; } void CalculateAAS() { double angle1 = 0.00; double angle2 = 0.00; double side1 = 0.00; WriteLine("AAS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: Known Values: 2 sides and the 1 angle between them"); WriteLine("Sought Values: 2 angles and the 1 sides between them"); WriteLine("----------------------------------------------------------------------"); try { Write("AAS Angle 1: "); angle1 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the lower left angle of the AAS shape."); } try { Write("AAS Angle 2: "); angle2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the lower right angle of the AAS shape."); } try { Write("AAS Side 1: "); side1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for the right side of the AAS shape."); } // Here, we use the law of sines double angle3 = 180 - (angle1 + angle2); double side2 = side1 * Math.Sin(angle2 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); double side3 = side1 * Math.Sin(angle3 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("AAS Angle 3: " + angle3.ToString()); WriteLine("AAS Side 2: " + side2.ToString()); WriteLine("AAS Side 3: " + side3.ToString()); } void CalculateASA() { double angle1 = 0.00; double angle2 = 0.00; double side1 = 0.00; WriteLine("ASA Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: 2 angles and the 1 side joining them"); WriteLine("Sought Values: 2 sides and the 1 angle between them"); WriteLine("----------------------------------------------------------------------"); try { Write("ASA Angle 1: "); angle1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for one of the known angles of the ASA shape."); } try { Write("ASA Side 1: "); side1 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the side that is between the angles whose values are about the ASA shape."); } try { Write("AAS Angle 2: "); angle2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the other known angle of the ASA oblique triangle."); } // Here, we use the law of sines double angle3 = 180 - (angle1 + angle2); double side2 = side1 * Math.Sin(angle2 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); double side3 = side1 * Math.Sin(angle3 * Math.PI / 180) / Math.Sin(angle1 * Math.PI / 180); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("ASA Angle 3: {0}", angle3); WriteLine("ASA Side 2: {0}", side3); WriteLine("ASA Side 3: {0}", side2); } void CalculateSAS() { WriteLine("SAS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: 2 sides and 1 angle"); WriteLine("Sought Values: 1 unknown side and 2 unknown angles"); WriteLine("----------------------------------------------------------------------"); WriteLine("Type the known values"); double side1 = GetSASSide1(); double angle1 = GetSASAngle1(); double side2 = GetSASSide2(); // Here, we use the law of cosines double side3 = Math.Sqrt((side1 * side1) + (side2 * side2) - (2 * side1 * side2 * Math.Cos(angle1 * Math.PI / 180))); double angle2 = Math.Acos(((side3 * side3) + (side2 * side2) - (side1 * side1)) / (2 * side3 * side2)) * 180 / Math.PI; double angle3 = 180 - (angle1 + angle2); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("SAS Side 3: {0}", side3.ToString()); WriteLine("SAS Angle 2: {0}", angle2.ToString()); WriteLine("SAS Angle 3: {0}", angle3.ToString()); } void CalculateSSS() { WriteLine("SSS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: All 3 sides"); WriteLine("Sought Values: All 3 angles"); WriteLine("----------------------------------------------------------------------"); double side1 = 0.00; double side2 = 0.00; double side3 = 0.00; WriteLine("Type the known values"); try { Write("SSS Side 1: "); side1 = double.Parse(ReadLine()!); } catch (FormatException) { WriteLine("You must type a value for one of the known sides of the SSS shape."); } try { Write("SSS Side 2: "); side2 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for another side of the SSS triangle."); } try { Write("SSS Side 3: "); side3 = Convert.ToDouble(ReadLine()); } catch (FormatException) { WriteLine("You must type a value for the remaining known side of the SSS oblique triangle."); } // Here, we use the law of cosines double angle1 = Math.Acos(((side3 * side3) + (side2 * side2) - (side1 * side1)) / (2 * side3 * side2)) * 180 / Math.PI; double angle2 = Math.Acos(((side3 * side3) + (side1 * side1) - (side2 * side2)) / (2 * side3 * side1)) * 180 / Math.PI; double angle3 = 180 - (angle1 + angle2); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine($"SSS Angle 1: {angle1}"); WriteLine($"SSS Angle 2: {angle2}"); WriteLine($"SSS Angle 3: {angle3}"); } WriteLine("======================================================================"); WriteLine("This application allows you to make calculations on oblique triangles"); WriteLine("======================================================================"); Title = "Oblique Triangles"; WriteLine("Available shape options:"); WriteLine("1 - AAS (Known: Angle - Angle - Side)"); WriteLine("2 - ASA (Known: Angle - Side - Angle)"); WriteLine("3 - SAS (Known: Side - Angle - Side)"); WriteLine("4 - SSS (Known: Side - Side - Side)"); WriteLine("Q - Quit"); Write("What type of triangle do you want to process? "); string selection = ReadLine()!; switch (selection) { case null: break; case "4": CalculateSSS(); break; case "3": CalculateSAS(); break; default: break; case "1": CalculateAAS(); break; case "2": CalculateASA(); break; } WriteLine("======================================================================");
Options on Debugging a Function
The Return Value of a Function
When going through a debugging session, if your code includes a function that returns a value, you can monitor the return value of a function. You can check such a value before the function is called, while the function has the debugging focus, or after the function has been called.
Practical Learning: Checking the Return Value of a Function
====================================================================== This application allows you to make calculations on oblique triangles ====================================================================== Available shape options: 1 - AAS (Known: Angle - Angle - Side) 2 - ASA (Known: Angle - Side - Angle) 3 - SAS (Known: Side - Angle - Side) 4 - SSS (Known: Side - Side - Side) Q - Quit What type of triangle do you want to process? 3 SAS Shape ---------------------------------------------------------------------- Known Values: 2 sides and 1 angle Sought Values: 1 unknown side and 2 unknown angles ---------------------------------------------------------------------- Type the known values SAS Side 1: 15 SAS Angle 1: 28 SAS Side 2: 43.6 ====================================================================== Results ---------------------------------------------------------------------- SAS Side 3: 31.16190861517509 SAS Angle 2: 13.06071118397518 SAS Angle 3: 138.93928881602483 ====================================================================== Press any key to close this window . . .
using static System.Console; double GetValue(string identity, string msg) { double value = default; try { Write(identity); value = Convert.ToDouble(ReadLine()!); } catch (FormatException) { WriteLine(msg); } return value; } (double first, double second, double third) Calculate(TriangleType category, double known1, double known2, double known3) { double value1 = 0.00; double value2 = 0.00; double value3 = 0.00; switch (category) { case TriangleType.AngleAngleSide: // Here, we use the law of sines value1 = 180 - (known1 + known2); value2 = known3 * Math.Sin(known2 * Math.PI / 180) / Math.Sin(known1 * Math.PI / 180); value3 = known3 * Math.Sin(value1 * Math.PI / 180) / Math.Sin(known1 * Math.PI / 180); return (value1, value2, value3); case TriangleType.AngleSideAngle: // Here, we use the law of sines value1 = 180 - (known1 + known3); value2 = known2 * Math.Sin(known3 * Math.PI / 180) / Math.Sin(known1 * Math.PI / 180); value3 = known2 * Math.Sin(value1 * Math.PI / 180) / Math.Sin(known1 * Math.PI / 180); return (value1, value2, value3); case TriangleType.Unknown: return (0.00, 0.00, 0.00); case TriangleType.SideAngleSide: // Here, we use the law of cosines value1 = Math.Sqrt( (known1 * known1) + (known3 * known3) - (2 * known1 * known3 * Math.Cos(known2 * Math.PI / 180))); value2 = Math.Acos(((value1 * value1) + (known3 * known3) - (known1 * known1)) / (2 * value1 * known3)) * 180 / Math.PI; value3 = 180 - (known2 + value2); return (value1, value2, value3); default: return (0.00, 0.00, 0.00); case TriangleType.SideSideSide: // Here, we use the law of cosines value1 = Math.Acos(((known3 * known3) + (known2 * known2) - (known1 * known1)) / (2 * known3 * known2)) * 180 / Math.PI; value2 = Math.Acos(((known3 * known3) + (known1 * known1) - (known2 * known2)) / (2 * known3 * known1)) * 180 / Math.PI; value3 = 180 - (value1 + value2); return (value1, value2, value3); } } void CalculateAAS() { double angle1 = 0.00; double angle2 = 0.00; double side1 = 0.00; WriteLine("AAS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: Known Values: 2 sides and the 1 angle between them"); WriteLine("Sought Values: 2 angles and the 1 sides between them"); WriteLine("----------------------------------------------------------------------"); angle1 = GetValue("AAS Angle 1: ", "You must type a value for the lower left angle of the AAS shape."); angle2 = GetValue("AAS Angle 2: ", "You must type a value for the lower right angle of the AAS shape."); side1 = GetValue("AAS Side 1: ", "You must type a value for the right side of the AAS shape."); (double angle3, double side2, double side3) results = Calculate(TriangleType.AngleAngleSide, angle1, angle2, side1); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("AAS Angle 3: " + results.angle3.ToString()); WriteLine("AAS Side 2: " + results.side2.ToString()); WriteLine("AAS Side 3: " + results.side3.ToString()); } void CalculateASA() { double angle1 = 0.00; double angle2 = 0.00; double side1 = 0.00; WriteLine("ASA Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: 2 angles and the 1 side joining them"); WriteLine("Sought Values: 2 sides and the 1 angle between them"); WriteLine("----------------------------------------------------------------------"); angle1 = GetValue("ASA Angle 1: ", "You must type a value for one of the known angles of the ASA shape."); side1 = GetValue("ASA Side 1: ", "You must type a value for the side that is between the angles whose values are about the ASA shape."); angle2 = GetValue("ASA Angle 2: ", "You must type a value for the other known angle of the ASA oblique triangle."); (double angle3, double side2, double side3) results = Calculate(TriangleType.AngleSideAngle, angle1, side1, angle2); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("ASA Angle 3: {0}", results.angle3); WriteLine("ASA Side 2: {0}", results.side2); WriteLine("ASA Side 3: {0}", results.side3); } void CalculateSAS() { WriteLine("SAS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: 2 sides and 1 angle"); WriteLine("Sought Values: 1 unknown side and 2 unknown angles"); WriteLine("----------------------------------------------------------------------"); WriteLine("Type the known values"); double side1 = GetValue("SAS Side 1: ", "You must type a value for one of the known sides of the SAS shape."); double angle1 = GetValue("SAS Angle 1: ", "You must type a value for the known angle of the SAS shape."); double side2 = GetValue("SAS Side 2: ", "You must type a value for the other known side of the SAS shape."); (double side3, double angle2, double angle3) results = Calculate(TriangleType.SideAngleSide, side1, angle1, side2); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine("SAS Side 3: {0}", results.side3); WriteLine("SAS Angle 2: {0}", results.angle2); WriteLine("SAS Angle 3: {0}", results.angle3); } void CalculateSSS() { WriteLine("SSS Shape"); WriteLine("----------------------------------------------------------------------"); WriteLine("Known Values: All 3 sides"); WriteLine("Sought Values: All 3 angles"); WriteLine("----------------------------------------------------------------------"); double side1 = 0.00; double side2 = 0.00; double side3 = 0.00; WriteLine("Type the known values"); side1 = GetValue("SSS Side 1: ", "You must type a value for one of the known sides of the SSS shape."); side2 = GetValue("SSS Side 2: ", "You must type a value for another side of the SSS triangle."); side3 = GetValue("SSS Side 3: ", "You must type a value for the remaining known side of the SSS oblique triangle."); (double angle1, double angle2, double angle3) results = Calculate(TriangleType.SideSideSide, side1, side2, side3); WriteLine("======================================================================"); WriteLine("Results"); WriteLine("----------------------------------------------------------------------"); WriteLine($"SSS Angle 1: {results.angle1}"); WriteLine($"SSS Angle 2: {results.angle2}"); WriteLine($"SSS Angle 3: {results.angle3}"); } WriteLine("======================================================================"); WriteLine("This application allows you to make calculations on oblique triangles"); WriteLine("======================================================================"); Title = "Oblique Triangles"; WriteLine("Available shape options:"); WriteLine("1 - AAS (Known: Angle - Angle - Side)"); WriteLine("2 - ASA (Known: Angle - Side - Angle)"); WriteLine("3 - SAS (Known: Side - Angle - Side)"); WriteLine("4 - SSS (Known: Side - Side - Side)"); WriteLine("Q - Quit"); Write("What type of triangle do you want to process? "); string selection = ReadLine()!; switch (selection) { case null: break; case "4": CalculateSSS(); break; case "3": CalculateSAS(); break; default: break; case "1": CalculateAAS(); break; case "2": CalculateASA(); break; } WriteLine("======================================================================"); public enum TriangleType { Unknown = 0, AngleAngleSide = 100, AngleSideAngle = 200, SideAngleSide = 500, SideSideSide = 700 }
As you know already, you can create a function that uses one or more parameters. When degugging a document that has a function that uses at least one parameter, the debugger can give you information about the value of the parameter. you can get such information before the function is called, while a function is being accessed, and after the function has been called.
Practical Learning: Debugging the Parameters of a Function
====================================================================== This application allows you to make calculations on oblique triangles ====================================================================== Available shape options: 1 - AAS (Known: Angle - Angle - Side) 2 - ASA (Known: Angle - Side - Angle) 3 - SAS (Known: Side - Angle - Side) 4 - SSS (Known: Side - Side - Side) Q - Quit What type of triangle do you want to process? 2 ASA Shape ---------------------------------------------------------------------- Known Values: 2 angles and the 1 side joining them Sought Values: 2 sides and the 1 angle between them ---------------------------------------------------------------------- ASA Angle 1: 75 ASA Side 1: 50 ASA Angle 2: 6 ====================================================================== Results ---------------------------------------------------------------------- ASA Angle 3: 99 ASA Side 2: 5.410791409793597 ASA Side 3: 51.126510634345365 ====================================================================== Press any key to close this window . . .
|
|
|||
| Previous | Copyright © 2010-2026, FunctionX | Sunday 12 July 2026, 12:12 | Next |
|
|
|||