Question

Write a python program using Object Oriented and do the following: 1. create class "cat" with...

Write a python program using Object Oriented and do the following:
1. create class "cat" with the following properties: name, age (create constructor method: def __init__)
2. create class "adopter" with the following properties: name, phone
3. create class "transaction" with these properties: adopter, cat (above objects)
cat1 = "puffy, 2"
adopter1 = "Joe, 123"

Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>"

this can only be done with object oriented programming, no way else, python language

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class cat:
def __init__(self, name, age):
self.name = name
self.age = age
class adopter:
def __init__(self, name, phone):
self.name = name
self.phone = phone
class transaction:
def __init__(self, adopter, cat):
self.adopter = adopter
self.cat = cat   

obj1= cat("puffy",2)
obj2= adopter("Joe",123)
obj3= transaction(obj2,obj1)

print("Per Transaction 1",obj3.adopter.name,"has adopted", obj3.cat.name)

Add a comment
Know the answer?
Add Answer to:
Write a python program using Object Oriented and do the following: 1. create class "cat" with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program to create a set operation calculator applying object oriented programming principles discussed in...

    Write a program to create a set operation calculator applying object oriented programming principles discussed in the class so far. The set operation calculator need to be enclosed inside one class with different methods responsible for performing the different operations listed below. When the constructor (def __init__() ) is called during object instantiation, two separate objects of this class need to be instantiated two sets S1 and S2. These two set objects can be instantiated from two python lists taken...

  • 1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with...

    1) Using the Object-Oriented Programming Paradigm,implement the necessary code in Python creating a ‘Car’ class with a constructor that stores all the Car information (ID, MAKE, MODEL, YEAR , COLOR, MILEAGE, PRICE_TO_DEALER, SALE_PRICE, PROFIT) as attributes. 2) Implement and add the following methods to the ‘Car' class in Question 1. a) necessary getter methods b) necessary setter methods c) method to display all the information to the screen d) a method to calculate the profit

  • Please use python Programming Language: Select one of the following topics: Band Character Account Create a...

    Please use python Programming Language: Select one of the following topics: Band Character Account Create a class based on your chosen topic. Make sure to include at least four attributes of varying types, a constructor, getters/setters for each attribute w/input validation, a toString, a static attribute, and a static method. Then, create a function (outside of your class) that connects to a text file which should contain the attributes of several objects. Read the data from the file, use the...

  • Write Python code to create a class called Dog which represents a dog. The Dog class...

    Write Python code to create a class called Dog which represents a dog. The Dog class should have properties of breed (i.e. what type of dog it is), name and weight. The class should also have a constructor that takes these parameters to initialise the dog object, and a method called bark that prints out the word 'Woof!' to the screen. After you have defined the Dog class, create a Dog object called goodDog with a breed of 'terrier', a...

  • Match the following: Inheritance: Encapsulation: Polymorphism: Modularization: Separation of concerns: DRY Principle: Object oriented programming: Procedural...

    Match the following: Inheritance: Encapsulation: Polymorphism: Modularization: Separation of concerns: DRY Principle: Object oriented programming: Procedural programming: Matlab is heavily used in: Python is heavily used in: [Choices are]: Child classes automatically get properties and methods of parents Outlines the procedure by which pseudo-code is turned into code Large-scale consumer commercial software programs Properties and methods can be private, protected or public The fastest growing language in terms of popularity Most modern large-scale software programs Breaks down a program into...

  • 1. Please write the following program in Python 3. Also, please create a UML and write...

    1. Please write the following program in Python 3. Also, please create a UML and write the test program. Please show all outputs. (The Fan class) Design a class named Fan to represent a fan. The class contains: Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denote the fan speed. A private int data field named speed that specifies the speed of the fan. A private bool data field named on that specifies...

  • ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for...

    ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for employees. Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class...

  • Object Oriented Programming C++ using class I need users (customers) to input their name and id....

    Object Oriented Programming C++ using class I need users (customers) to input their name and id. Program needs to have a menu: 1. Create - input id, name 2. List - see all the list of the users 3. Exit. It should be limited to 20 users only.

  • Write three object-oriented classes to simulate your own kind of team in which a senior member...

    Write three object-oriented classes to simulate your own kind of team in which a senior member type can give orders to a junior member type object, but both senior and junior members are team members. So, there is a general team member type, but also two specific types that inherit from that general type: one senior and one junior. Write a Python object-oriented class definition that is a generic member of your team. For this writeup we call it X....

  • USE PYTHON CODING ####################### ## ## Definition for the class Pet ## ######################## class Pet: owner=""...

    USE PYTHON CODING ####################### ## ## Definition for the class Pet ## ######################## class Pet: owner="" name="" alive=False def __init__(self,new_name): self.name=new_name self.alive=True Using the code shown above as a base write a code to do the following: - Create a separate function (not part of the class) called sameOwner which reports whether two pets have the same owner. test it to be sure it works - Add a variable age to Pet() and assign a random value between 1 and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT