calthoff / tstp

This is an old repository for the exercises in "The Self-Taught Programmer." Please see /selftaught.
166 stars 193 forks source link

Ch. 13, Challenge 2 #6

Closed jonathan-j-stone closed 7 years ago

jonathan-j-stone commented 7 years ago
def change_size(self, new_size):
    self.s1 = new_size

This doesn't seem to solve the challenge according to the directions, which require us to create a method that "allows you to pass in a number that increases or decreases (if the number is negative) each side of a Square object by that number." (emphasis mine)

Your solution only changes the value of each side of the square by the new value that is passed in, it doesn't increase it or decrease it. If I pass in a negative number, it would result in a square with negative side length.

In order to conform to the challenge, should the result look like this?

 def change_size(self, new_size):
        self.s1 = self.s1 + new_size

And while I'm here, why wouldn't we use a 'return' statement with this method? Could we?

calthoff commented 7 years ago

@ILeftTheLaw You are correct! Sorry about that. I will fix it.