using System; using System.Xml; namespace Triangle { /// /// A right angle triangle. /// [Serializable] public class Triangle: IComparable { /// /// A side of the triangle. /// public double A {get; set;} /// /// A side of the triangle. /// public double B {get; set;} /// /// A side of the triangle. /// public double C { get { return Math.Sqrt(A*A + B*B); } } /// /// The area of the triangle. /// public double S { get { return A * B / 2; } } public Triangle() { } public override string ToString() { return $"A: {A:f2} \tB: {B:f2} \tC: {C:f2} \tS: {S:f2}"; } int IComparable.CompareTo(Triangle other) { return (other.S/other.C).CompareTo(S/C); } } }