-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcar.py
More file actions
22 lines (16 loc) · 715 Bytes
/
car.py
File metadata and controls
22 lines (16 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from typing import Any
class Car:
"""Contains the information for a car."""
def __init__(self, name: str, orientation: str, col: int, row: int, length: int) -> None:
self.name = name
self.orientation = orientation
self.col = col
self.row = row
self.length = length
def __str__(self) -> str:
return "Car({0}, {1}, {2}, {3}, {4})".format(self.name, self.orientation, self.col, self.row, self.length)
def __hash__(self) -> int:
"""Method which returns a hash based on the name, column, and row of a car."""
return hash((self.name, self.col, self.row))
def __eq__(self, other: Any) -> bool:
return isinstance(other, Car)