Question: Write a class named Marsupial that can be used as shown below: >>> m = Marsupial() >>> m.put_in_pouch('doll') >>> m.put_in_pouch('firetruck') >>> m.put_in_pouch('kitten') >>> m.pouch_contents() ['doll',
Write a class named Marsupial that can be used as shown below: >>> m = Marsupial() >>> m.put_in_pouch('doll') >>> m.put_in_pouch('firetruck') >>> m.put_in_pouch('kitten') >>> m.pouch_contents() ['doll', 'firetruck', 'kitten']
Now write a class named Kangaroo as a subclass of Marsupial that inherits all the attributes of Marsupial and also: a. extends the Marsupial __init__ constructor to take, as input, the coordinates x and y of the Kangaroo object, b. supports method jump that takes number values dx and dy as input and moves the kangaroo by dx units along the x-axis and by dy units along the yaxis, and c. overloads the __str__ operator so it behaves as shown below.
>>> k = Kangaroo(0,0)
>>> print(k)
I am a Kangaroo located at coordinates (0,0)
>>> k.put_in_pouch('doll')
>>> k.put_in_pouch('firetruck')
>>> k.put_in_pouch('kitten')
>>> k.pouch_contents()
['doll', 'firetruck', 'kitten']
>>> k.jump(1,0)
>>> k.jump(1,0)
>>> k.jump(1,0)
>>> print(k)
I am a Kangaroo located at coordinates (3,0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
