Write a class named animal with the following attributes

Assignment Help Python Programming
Reference no: EM132360806

Zoo Class

In this programming assignment, you will create the following:

• An Animal class that stores information about an animal.

• A Zoo class that stores and displays Animal objects.

• A zookeeper program that uses the Animal and Zoo classes.

These elements are described below.

Animal Class

Write a class named Animal with the following attributes and methods. Save this  class as Animal.py

Attributes
__animal_type: a hidden attribute used to indicate the animal's type. For example: gecko, walrus, tiger, etc.
__name: a hidden attribute used to indicate the animal's name.
__mood: a hidden attribute used to indicate the animal's mood. For example: happy, hungry, or sleepy.

Methods
__init__: this method should create the three attributes above and assign their default values.

The value of __mood should be set randomly. Generate a random number between 1 and 3. Then:
If the number is 1, the __mood field should be set to a value of "happy".
If the number is 2, the __mood field should be set to a value of "hungry".
If the number is 3, the __mood field should be set to a value of "sleepy".
get_animal_type: this method should return the value of the __animal_type field.
get_name: this method should return the value of the __name field.
check_mood: this method should return the value of the __mood field.

Zoo Class

Write a class named Zoo with the following attributes and methods. Save this class as Zoo.py

Attributes
__animals: a list used to store Animal objects.

Methods

__init__: use this method to create an empty list for __animals.

add_animal: this method should receive an Animal object and append it to the __animals list.

show_animals: this method will print information about each of the Animal objects within __animals. If no Animals have been added to the
list, it should print out a message saying that there are no Animals.

Zookeeper Program

Once you have written the Animal and Zoo classes, create another program called zookeeper.py. This program will use Animal.py and Zoo.py as modules.

In zookeeper.py, create a Zoo object and print a menu with three options: Add Animal, Show Animals, and Exit.

Add Animal: choosing this option should prompt the user to enter the type and name of an Animal. Use that input to create an Animal object and use the Zoo object's add_animal method to store the animal.

Show Animals: choosing this option should trigger the Zoo object's show_animals method.

Exit: this should exit the program.

If exit is not selected, the program should loop and display the options again.

Error Checking

Invalid input should not cause the program to crash. Make sure to handle errors properly.

Testing

Run the program you write and verify that the information entered matches the information displayed and that the input prompts and output utilize the format specification provided.

Reference no: EM132360806

Questions Cloud

Benefits of having a diverse workplace : Identifies the benefits of having a diverse workplace. provide this analysis based on the strategic goals listed - leadership
Identify good reasons to make change : Why is it important to identify good reasons to make change in an organization. Provide an example of an organization that you believe has managed change well.
Ensure compliance with policies and procedures : List five (5) steps to ensure compliance with policies and procedures.
Help me to explain power bases : Help me to Explain power bases. How does one build power within an organization? How are power and politics related within an organization?
Write a class named animal with the following attributes : InfoTc 1040 Introduction to Problem Solving and Programming-Write a class named Animal with the following attributes and methods.
Improving the well-being of consumers : What are Walmart's contributions to improving the well-being of consumers and the economic sustainability of society?
Types of social media : Construct a 10 min. Power Point Presentation outline how it can benefit the company by using various types of social media through big data.
Yourself doubting your own ability to accomplish goal : Have you ever found yourself doubting your own ability to accomplish a goal? If so, which goal?
Create a program to predict the amount of money : Create a program to predict the amount of money you will have in your IRA when you retire. Number of years until you retire, it must be a whole number.

Reviews

Write a Review

Python Programming Questions & Answers

  Implement a program for a user to manipulate a readinglist

Define a function called print List that takes in a list as a parameter and prints the entries in the listone entry per line. Implement a program for a user.

  Take a set of six grades from a user and average them

First, take a set of 6 grades from a user and average them. Provide the average to the user. You need to check to make sure the grades are within normal range.

  Write a python function named numvowels

Write a Python function named numVowels that is passed a string containing letters, each of which may be in either uppercase or lowercase.

  Ida to reverse engineer a piece of shellcode

You are a Malware Investigator at 0xC0ff33, Inc and an incident responder came across injected shellcode during an investigation. He has done all he can in IDA and has passed on the .idb file to you. Figure out what the purpose of the malware was ..

  Create an inheritance relationship between two classes

For this assignment you will create a simple class hierarchy. You will create an inheritance relationship between two classes -- a Friend class and a Person class - Friend will inherit Person

  Write a short program in python that turns on all leds

Write a short program in Python that turns on all LEDs, one at a time, in a looping fashion. When an LED is on, it should stay on for 1 second.

  Calculate the accuracy of your linear classifier

Plot X,Y and the decision boundary. Make sure that you use a good plotting technique so that it is easy to distinguish which datapoint is X and which is Y. Calculate the accuracy of your linear classifier.

  Write a program that counts the frequencies of each word

Write a program that counts the frequencies of each word in a text, and output each word with its count and line numbers where it appears. We define a word as a contiguous sequence of non-white-space characters.

  What relationships and properties do you need to model

Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard - What relationships and properties

  Create a file to store usernames and passwords

Create file called "store_passwords.py" where you ask users to provide usernames and passwords that you will store in a JSON file called "password_store.json"

  Add a new function called print box to your program

Add a new function called print_box to your program. print_box will manage the other three functions by calling et_size to get a number from the user.

  Implement a function that takes a filename as input

FIT1008 - Implement a function that takes a filename as input and reads it into an instance of the class you implemented on Task 2. For each line in the file

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd