On Tue, 6 Oct 2020 at 15:33, Alperen Keleş <[email protected]> wrote:
> Cars have different states, MovingCar, IdleCar, ParkingCar...
Well, IMHO the solution is quite more simple:
class Car:
def __init__(self):
self.state = "parking"
def move(self):
if self.state != "moving":
raise StateException("car can't move!")
[...]
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/5P2WVGDX6HFUY2JMKJZ7OQP5YGJ5F6PL/
Code of Conduct: http://python.org/psf/codeofconduct/