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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
)a grad student comes up with the following algorithm to sort an array a[1..n] that works by first sorting the first 2/3rds of the array, then sorting the last 2/3rds of the (resulting) array, and finally sorting the first 2/3rds of the new array. 1: function g-sort(a, n) . takes as input an array of n numbers, a[1..n] 2: g-sort-recurse(a, 1, n) 3: end function 4: function g-sort-recurse(a, `, u) 5: if u ⒠` ≤ 0 then 6: return . 1 or fewer elements already sorted 7: else if u ⒠` = 1 then . 2 elements 8: if a[u] < a[`] then . swap values 9: temp ↠a[u] 10: a[u] ↠a[`] 11: a[`] ↠temp 12: end if 13: else . 3 or more elements 14: size ↠u ⒠` + 1 15: twothirds ↠d(2 ◠size)/3e 16: g-sort-recurse(a, `, ` + twothirds ⒠1) 17: g-sort-recurse(a, u ⒠twothirds + 1, u) 18: g-sort-recurse(a, `, ` + twothirds ⒠1) 19: end if 20: end function first (5 pts), prove that the algorithm correctly sorts the numbers in the array (in increasing order). after showing that it correctly sorts 1 and 2 element intervals, you may make the (incorrect) assumption that the number of elements being passed to g-sort-recurse is always a multiple of 3 to simplify the notation (and drop the floors/ceilings).
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
What is the term for water wave that is created by an underwater earthquake
Answers: 1
question
Computers and Technology, 25.06.2019 05:00
7. the cullerton park district holds a mini-olympics each summer. create a class named participant with fields for a name, age, and street address. include a constructor that assigns parameter values to each field and a tostring() method that returns a string containing all the values. also include an equals() method that determines two participants are equal if they have the same values in all three fields. create an application with two arrays of at least eight participants each—one holds participants in the mini-marathon, and the other holds participants in the diving competition. prompt the user for participant values. after the data values are entered, display values for participants who are in both events. save the files as participant.java and twoeventparticipants.java.
Answers: 2
question
Computers and Technology, 25.06.2019 05:10
Assume that two parallel arrays have been declared and initialized: healthoption an array of type char that contains letter codes for different healthcare options and annual cost an array of type int. the i-th element of annual cost indicates the annual cost of the i-th element of healthoption. in addition, there is an char variable, best2.write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. thus, if the values of healthoption are 'b', 'q', 'w', 'z' and the values of annualcost are 8430, 9400, 7050, 6400 your code would assign 'b' to best2 because 8430 is less than 9400 and is associated with 'b' in the parallel array. (we ignore 'w' and 'z' because we are considering only the first two options.)
Answers: 1
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
question
Mathematics, 21.12.2020 05:00
question
Mathematics, 21.12.2020 05:00
question
Mathematics, 21.12.2020 05:00
question
Mathematics, 21.12.2020 05:00
question
English, 21.12.2020 05:00
Questions on the website: 13722365