# Магические методы сравнения
# __eq__ - ==
# __ne__ - !=
# __lt__ <
# __le__ <=
# __gt__ >
# __ge__ >=

from functools import total_ordering

class Rectangle:

    def __init__(self, a, b) -> None:
        self.a = a
        self.b = b

    @property
    def area(self):
        return self.a * self.b

    def __eq__(self, other):
        if isinstance(other, Rectangle):
            return self.a == other.a and self.b == other.b
        
    def __eq__(self, other):
        if isinstance(other, Rectangle):
            return self.area < other.area
        elif isinstance(other, (int, float)):
            return self.area < other
        
    def __le__(self, other):
        return self==other or  self<other


class Point:
    
    def __init__(self, x, y) -> None:
        self.x = x
        self.y = y

    def __eq__(self, other: object) -> bool:
        return isinstance(other, Point) and \
            self.x == other.x and self.y == other.y
        
    def __hash__(self):
        return hash((self.x, self.y))


@total_ordering
class Fruit:

    def __init__(self, name, price):
        self.name = name
        self.price = price

    def __eq__(self, value: object) -> bool:
        if isinstance(value, (int, float)):
            return self.price == value
        elif isinstance(value, Fruit):
            return self.price == value.price
        else:
            raise ValueError

    def __lt__(self, value):
        if isinstance(value, (int, float)):
            return self.price < value
        elif isinstance(value, Fruit):
            return self.price < value.price
        else:
            raise ValueError

def main():
    apple = Fruit("Apple", 0.5)
    orange = Fruit("Orange", 1)
    banana = Fruit("Banana", 1.6)
    lime = Fruit("Lime", 1.0)

    assert (banana > 1.2) is True
    assert (banana >= 1.2) is True
    assert (banana == 1.2) is False
    assert (banana != 1.2) is True
    assert (banana < 1.2) is False
    assert (banana <= 1.2) is False

    assert (apple > orange) is False
    assert (apple >= orange) is False
    assert (apple == orange) is False
    assert (apple != orange) is True
    assert (apple < orange) is True
    assert (apple <= orange) is True

    assert (orange == lime) is True
    assert (orange != lime) is False
    assert (orange > lime) is False
    assert (orange < lime) is False
    assert (orange <= lime) is True
    assert (orange >= lime) is True
    print('Good')

if __name__ == '__main__':
    main()