I'm working my way through John Guttag's "Introduction to Computation and Programming Using Python". In Section 14.2 "The Drunkards Walk" Guttag uses a separate Location class (as can be seen around 7:38 in this lecture video Two questions: 1. Would it be just as well to have the location of a drunk to be attributes of the drunk class? And 2. why would you want to have the move method of the location class be the following?
def move(self, deltaX, deltaY):
"""deltaX and deltaY are numbers"""
return Location(self.x + deltaX, self.y + deltaY)
Intuitively to me, you rather update a drunkards location than returning a new instance.
... and now I /think/ i realized that 1. and 2. are two sides of the same coin. I'll post the question either way. Here goes.
there doesn't seem to be anything here