diff --git a/SRT/passenger.py b/SRT/passenger.py index f661c64..dfa6bb0 100644 --- a/SRT/passenger.py +++ b/SRT/passenger.py @@ -22,11 +22,16 @@ def __repr__(self): return f"{self.name} {self.count}명" def __add__(self, other: "Passenger") -> "Passenger": - assert isinstance(other, self.__class__) + if not isinstance(other, self.__class__): + raise TypeError("Passenger types must be the same") + if self.type_code == other.type_code: new_count = self.count + other.count return self.__class__(count=new_count) + raise ValueError("Passenger types must be the same") + + @classmethod def combine(cls, passengers: list["Passenger"]) -> list["Passenger"]: if list(filter(lambda x: not isinstance(x, Passenger), passengers)):