Question: python Write 02 classes, super class Animal and sub-class Dog with the following details: Write a class Animal with class attributes, stuff_in_belly and position. Initialize

python

Write 02 classes, super class Animal and sub-class Dog with the following details:

  1. Write a class Animal with class attributes, stuff_in_belly and position. Initialize both class variables with 0.
  2. Write init method and initialize the name and color instance variables. Write an instance method, talk that takes sound as a parameter, specify the default value to None. talk method """Return the string " says and If `sound` is left out, returns "Hello, I'm ".
  3. write another instance method, walk, that takes a numeric value walk_increment as parameter and changes the position by adding the walk_increment.
  4. Similarly, add another method, run, that takes run_increment as parameter and changes the position by adding the run_increment.
  5. Write another method, feed, that should increment the stuff_in_belly by 1 and check if stuff_in_belly is more than 3, call discharge method to set the stuff_in_belly to 0.
  6. Write discharge method that resets the stuff_in_belly variable.
  7. Write another method, is_hungry, that should return " is hungry" if the stuff_in_belly < 3 otherwise return message should be " is not hungry".
  8. Write a sub-class Dog, inherit from super class Animal and add 02 methods, talk and fetch. The talk method should have the default sound of "Bark Bark" and fetch method should return string " is fetching"
  9. python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!