Create a Python file called adopter.py. In this file, write a class called Adopter that matches the following docstring: '''

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a Python file called adopter.py. In this file, write a class called Adopter that matches the following docstring:

'''
Class -- Adopter
Represents a person that would like to adopt a pet.
Attributes:
name -- The adopter's name, a string.
species_choice -- The species the person would like to adopt e.g. "cat" or "dog"
has_pets -- A boolean, which indicates whether or not the adopter already
has pets.
Method:
...See part B...
'''

Important: make sure the attributes are passed to the constructor in the order shown above. Here's an example showing how an Adopter object will be created:

mr_t = Adopter("Mr. T", "cat", False)

The adopter's name is Mr. T, he would like to adopt a cat, and he does not currently have any pets at home.

Part B

Add a method called is_match to the Adopter class. The method should take a parameter, an instance of a Pet class and return True if the Adopter would be a good match for the Pet and False if not. You do not need to write the Pet class—you can assume someone else has already written it. 

Here is all the information you will need:

  • The Pet class has two attributes that you will need to use for this part:
    • species — a string describing the Pet's species e.g. "cat"
    • can_live_with_pets — a boolean which is True if the Pet can live with other pets (meaning it gets along with other animals) and False if not.
  • To be considered a match:
    • The species of the Pet must match the Adopter's species choice e.g. If the Adopter is looking for a "cat", the Pet must be a "cat". You do not need to worry about string case or spelling of the species e.g. "Cat" would not be a match for "cat".
    • If the Adopter has pets, the Pet must be able to live with other pets (assuming the species requirement is met).
    • If the Adopter does not have pets, they can be matched with any Pet of the appropriate species.

Here is an example:

fluffy_the_cat = Pet("Fluffy", "cat", True) # Fluffy is a cat that can live with other pets
spot_the_dog = Pet("Spot", "dog", False) # Spot is a dog that cannot live with other pets
mr_t = Adopter("Mr. T", "cat", False)
mr_t.is_match(fluffy_the_cat) # should return True
mr_t.is_match(spot_the_dog) # should return False

Part C 

Implement a method in your Adopter class that will make it possible to compare two Adopterobjects using the == operator. Two Adopters should be considered equal if the values of all of their attributes are the same.

Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education