subject

Write a class named Pet, with should have the following data attributes:1._name (for the name of a pet.2._animalType (for the type of animal that a pet is. Example, values are "Dog","Cat" and "Bird")3._age (for the pet's age)The Pet class should have an __init__method that creates these attributes. It should also have the following methods:-setName -This method assigns a value to the_name field-setAnimalType - This method assigns a value to the __animalType field-setAge -This method assigns a value to the __age field-getName -This method returns the value of the __name field-getAnimalType -This method returns the value of the __animalType field-getAge - This method returns the value of the __age fieldWrite a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This should be stored as the object's attributes. Use the object's accessor methods to retrieve the pet's name, type and age and display this data on the screen. Also add an __str__ method to the class that will print the attributes in a readable format. In the main part of the program, create two more pet objects, assign values to the attirbutes and print all three objects using the print statement. Note: This program must be written using Python language

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:30, AsiaDeas4078
Write lines of verse that rhyme to remember the following information: acid rain is a type of air pollution caused by chemicals in the air.
Answers: 1
image
Computers and Technology, 24.06.2019 01:30, Cinders13
How can you make your column headings stand out?
Answers: 1
image
Computers and Technology, 24.06.2019 10:30, johngayden46
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
image
Computers and Technology, 24.06.2019 13:00, juuuuuu42
George heard about the benefits of a data warehouse. he wants to try implementing one for his organization. however, he is afraid that transferring data to the data warehouse will affect transaction time. which element ensures that transactions are not affected when moving data to a warehouse? when data is transferred to a data warehouse, the a area frees the source system to continue transaction processing.
Answers: 2
You know the right answer?
Write a class named Pet, with should have the following data attributes:1._name (for the name of a p...

Questions in other subjects:

Konu
English, 28.09.2021 20:30
Konu
Social Studies, 28.09.2021 20:30
Konu
Chemistry, 28.09.2021 20:30
Konu
Mathematics, 28.09.2021 20:30