Program Assignment
Write a class named Pet, with should have the following data attributes: • _name (for the name of a pet) • _animalType ((for the type of animal that a pet is. Example, values are “Dog” , “Cat” and “Bird”) • _age (for the pet’s age) The Pet class should have an init method that creates these attributes. lt 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 field Once you have written the class, write 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 ExtraCredit-5points Add an _str_ method to the class that will print the attributes in a readable format. ln the main part of the program, create two more Pet objects, assign values to the attributes and print all three objects using the print statement.
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


