diff --git a/stock.py b/stock.py index 2bbc98c..c4881d5 100644 --- a/stock.py +++ b/stock.py @@ -7,6 +7,18 @@ class Stock: self.shares = shares self.price = price + def __repr__(self): + return f"Stock({self.name!r}, {self.shares!r}, {self.price!r})" + + def __eq__(self, other): + if not isinstance(other, Stock): + return False + return (self.name, self.shares, self.price) == ( + other.name, + other.shares, + other.price, + ) + @classmethod def from_row(cls, row): values = [func(val) for func, val in zip(cls._types, row)]