/// <summary> /// Define weather the triangle is right /// </summary> /// <returns>True, if triangle is right</returns> public bool IsRight() { if (SideA.Equals(Math.Pow(SideB * SideB + SideC * SideC, 0.5)) || SideB.Equals(Math.Pow(SideA * SideA + SideC * SideC, 0.5)) || SideC.Equals(Math.Pow(SideB * SideB + SideA * SideA, 0.5))) { return(true); } return(false); }
// The ClearButton_Click Method // purpose: Clear the textboxes, and put the cursor back in the first text box // Parameters: The sending object, and the event arguments // Returns: none private void ClearButton_Click(object sender, EventArgs e) { // clear each text box. SideA.Clear(); SideB.Clear(); AngleC.Clear(); SideC.Clear(); AngleA.Clear(); AngleB.Clear(); // put the cursor back in the first text box. SideA.Select(); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="obj"> The object to compare with the current object.</param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(false); } Triangle tr = obj as Triangle; if (tr == null) { return(false); } return(SideA.Equals(tr.SideA) && SideB.Equals(tr.SideB) && SideC.Equals(tr.SideC)); }
static void Main(string[] args) { float SideA; float SideB; string input; float RectArea; Console.WriteLine("How long is side A?"); input = Console.ReadLine(); SideA = float.Parse(input); Console.WriteLine("\nHow long is side B?"); input = Console.ReadLine(); SideB = float.Parse(input); RectArea = SideA * SideB; Console.WriteLine("\nYou entered " + SideA.ToString() + " units for side A and " + SideB.ToString() + " units for side B."); Console.WriteLine("\nThe area of the rectangle is " + RectArea.ToString() + " units squared"); Console.ReadLine(); }
/// <summary> /// /// </summary> /// <returns></returns> public override int GetHashCode() { return(SideA.GetHashCode() ^ SideB.GetHashCode() ^ SideC.GetHashCode() ^ AngleA.GetHashCode() ^ AngleB.GetHashCode() ^ AngleC.GetHashCode()); }
public bool IsRightTriangle() { return(SideA.Equals(Math.Sqrt(Math.Pow(SideB, 2) + Math.Pow(SideC, 2))) || SideB.Equals(Math.Sqrt(Math.Pow(SideA, 2) + Math.Pow(SideC, 2))) || SideC.Equals(Math.Sqrt(Math.Pow(SideA, 2) + Math.Pow(SideB, 2)))); }
public override string ToString() { return(SideA.ToString() + "-" + SideB.ToString()); }
/// <summary> /// Get a hash code for the current object. /// </summary> /// <returns></returns> public override int GetHashCode() { return(3 * SideA.GetHashCode() + 2 * SideB.GetHashCode() - 2 * SideC.GetHashCode()); }