Основы объектно-ориентированного программирования на языке C# book | Page 150

7 Класи { if (x.a * y.b > x.b * y.a) return true; else return false; } public static bool operator <(Rational x, Rational y) { if (x.a * y.b < x.b * y.a) return true; else return false; } public static bool operator ==(Rational x, Rational y) { if (x.a == y.a && x.b == y.b) return true; else return false; } public static bool operator !=(Rational x, Rational y) { if (x.a != y.a || x.b != y.b) return true; else return false; } public static bool operator >=(Rational x, Rational y) { if (x.a * y.b >= x.b * y.a) return true; else return false; } public static bool operator <=(Rational x, Rational y) { if (x.a * y.b <= x.b * y.a) return true; else return false; } public override bool Equals(object o) { if (o.GetType() != GetType()) return false; Rational t = (Rational)o; return (a == t.a && b == t.b); } public override int GetHashCode() { return 0; } } class Program { public static void Main(string[] args) { Rational x = new Rational(2, 5); Console.Write("Вихiдний дрiб x="); 150