Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Zoo class
#1
hi'
i need to built a class for zoo
and i need some help

that is the code so far
==================

class Animal:
    def __init__(self,_name,_hunger ):
        self._name =_name
        self._hunger= 0

    class Dog():
        def __init__(self,_name,_hunger ):
            pass
        
    class cat():
        def __init__(self,_name,_hunger ):
            pass
        
    class Skunk():
        def __init__(self,_name,_hunger ):
            pass
        
    class Unicorn():
        def __init__(self,_name,_hunger ):
            pass
        
    class Dragon():
        def __init__(self,_name,_hunger ):
            pass

def main():
  
    for animal in zoo_lst:
        while animal.is_hungry():
             animal.feed()
======================

id have to Write a main function called main that performs the following tasks:

Creates one animal of each type (Unicorn, Skunk, Cat, Dog, and Dragon) and initializes it with the values listed in the table. She keeps the shows of the animals in the list called zoo_lst.
Goes through the animals in the zoo_lst list using the for loop. For each hungry animal, prints its type (type, subdivision name) and its name (name_) and then feeds it until it is no longer hungry (that is, until its degree of hunger is 0).
Instructions: You can use the following code skeleton.

any help how to start ?
and where to put the main def ?
Reply


Messages In This Thread
Zoo class - by saaat - Dec-02-2019, 03:23 AM
RE: ZOO CLASS - by Larz60+ - Dec-02-2019, 04:38 AM
RE: ZOO CLASS - by buran - Dec-02-2019, 06:45 AM
RE: Zoo class - by jefsummers - Dec-02-2019, 02:50 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020