Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python 3.6 some files you may need: lab13.py:https://www.cse.msu.edu/~cse231/Labs/Lab13/lab13.py pets.py:https://www.cse.msu.edu/~cse231/Labs/Lab13/pets.py l. Examine the file named lab13.py, which contains a simple test bed for the classes

image text in transcribedimage text in transcribed

Use python 3.6

some files you may need:

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

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

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 ca and rest lower case hint: title0) 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 of 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

More Books

Students also viewed these Databases questions