Skip to content

Commit

Permalink
type
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking13 committed Aug 26, 2024
1 parent 0d50f8a commit 98b080a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion SRT/passenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down

0 comments on commit 98b080a

Please sign in to comment.