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...

  • Question set 1 (Java) object oriented: 1.Write a class called Student. The class should be able...

    Question set 1 (Java) object oriented: 1.Write a class called Student. The class should be able to store information regarding the name, age, gpa, and phone number of a Student object. Please write all the setter and getter methods. Finally, write a Demo class to demonstrate the use of the class by creating two different objects. 2.Use the same Student class from the previous problem. This time,you will write a different Demo class, in which you will create three Student...

  • 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...

  • Python Program: Design a class Write a class called Sport that has a single attribute teamSize....

    Python Program: Design a class Write a class called Sport that has a single attribute teamSize. Write a parametrized constructor to initialize the object. Inherit this class into another class called Football, with attributes teamName and numChampionships. Write a parametrized constructor to initialize this object and a printStuff function. Then, create an object of Football and print the values. Sample Run: The values are: Team Size: 45 Team Name: Florida State Seminoles National Champions: 3 times

  • 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...

  • Objectives: Develop an object-oriented program Develop a test program that is separate from the class under...

    Objectives: Develop an object-oriented program Develop a test program that is separate from the class under development ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Define a class where one object of the class represents a playing card. If you are not familiar with a deck of playing cards, you will need to spend some time understanding the rank and suit that is on each playing card. You can look it up in wikipedia and see an image of the whole deck of 52 playing cards here:...

  • must be in python Part 1 - the Item class – An Item object will represent...

    must be in python Part 1 - the Item class – An Item object will represent one grocery item. Define a class named Item that has the following attributes: name – the name of the grocery item price – the price of the item quantity – the number of items that are needed The Item class should have an __init__ method for creating an Item object.   The __init__ method should accept parameters which provide initial values for the object:   ...

  • 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.

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