-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquest320.py
More file actions
42 lines (28 loc) · 1.44 KB
/
quest320.py
File metadata and controls
42 lines (28 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
#Make them bark
You have been hired by a dogbreeder to write a program to keep record of his dogs.
You've already made a constructor Dog, so no one has to hardcode every puppy.
The work seems to be done. It's high time to collect the payment.
..hold on! The dogbreeder says he wont pay you, until he can make every dog object .bark(). Even the ones already done with your constructor. "Every dog barks" he says. He also refuses to rewrite them, lazy as he is.
You can't even count how much objects that bastard client of yours already made. He has a lot of dogs, and none of them can .bark().
Can you solve this problem, or will you let this client outsmart you for good?
Practical info:
The .bark() method of a dog should return the string 'Woof!'.
The contructor you made (it is preloaded) looks like this:
class Dog(object):
def __init__(self, name, breed, sex, age):
self.name = name
self.breed = breed
self.sex = sex
self.age = age
Hint: A friend of yours just told you about how javascript handles classes diferently from other programming languages. He couldn't stop ranting about "prototypes", or something like that. Maybe that could help you...
"""
class Dog(object):
def __init__(self, name, breed, sex, age):
self.name = name
self.breed = breed
self.sex = sex
self.age = age
def bark(self):
return 'Woof!'
Dog.bark = classmethod(bark)