Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Test Output: Species of Hamster, unnamed Species of Dog, named Fido, chases Cats Species of Cat, named Fluffy, hates everything Got a pet error. lab13.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab13/lab13.py

image text in transcribed

image text in transcribed

Test Output:

Species of Hamster, unnamed

Species of Dog, named Fido, chases Cats

Species of Cat, named Fluffy, hates everything

Got a pet error.

lab13.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab13/lab13.py

pets.py:https://www.cse.msu.edu/~cse231/Online/Labs/Lab13/pets.py

This lab exercise provides practice with class inheritance in Python. Hint Code Listing 12.11 should be very helpful You will work with a partner on this exercise during your lab session. Two people should work at one computer. Occasionally switch the person who is typing. Talk to each other about what you are doing and why so that both of you understand each step l. Examine the file named "lab13.py", which contains a simple test bed for the classes in "pets.py", and then execute the test bed 2. Examine the file named "pets py", which contains an outline of four classes to support the handling of pets within Python programs. Please note that class "PetError" is a subclass of class "Exception" and is complete as-is. You will complete the remaining three classes as described below. Class "Pet" (which is a subclass of class "Object') should include the following methods: Accepts three arguments: self, species (default None), and name (default Stores init species and name as data attributes. Raises PetError, if species is not one of the following (case insensitive): 'dog', 'cat', 'horse', gerbil', 'hamster, ferret' Returns a string which depends on whether the pet is named or not. str if named: "Species of Xxx, named Yyy", where Xxx is the species data attribute and Yyy is the name data attribute, both in "title-case" (first letter upper case and rest lower case hint: title()) otherwise: "Species o Xxx, unnamed", where Xxx is the species data attribute in "title-case Class "Dog" (which is a subclass of class "Pet") should include the following methods: Accepts three arguments: self, name (default and chases (default "Cats"). Uses the init constructor for class "Pet" to store species ("Dog") and name as data attributes. Stores chases as a data attribute Hint: check out how MassParticle calls the Particle init in Code Listing 12.11 Returns a string which depends on whether the dog is named or not str Hint: call the Pet class str (see MassParticle's Str in Code Listing 12.11) if named: "Species of Dog, named Yyy, chases zzz where Yyy is the name data attribute (as above) and zzz is the chases data attribute. otherwise: "Species o Dog, unnamed, chases zzz", where zzz is the chases data attribute

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

Mention the bases on which consumer market can be segmented.

Answered: 1 week ago

Question

Explain consumer behaviour.

Answered: 1 week ago

Question

Explain the factors influencing consumer behaviour.

Answered: 1 week ago