Question
Python: Create your own class to model data for a business that sells something for your favorite hobby or interest. Make sure to have 2
Python: Create your own class to model data for a business that sells something for your favorite hobby or interest. Make sure to have 2 numeric variables to do calculations with (like a quantity and price for a total, or a size or type for different part prices, and a text variable (you can have more than one but keep it to three as a maximum so your class is not too big) to keep a description or two about your new data class. Make sure that the variables are stored inside the objects of your class by having them in the class using the self. And also have get() and Set() functions for these internal variables.
Include an __init__ as a constructor for your class that takes all of the data you need to make a new object of your class. Set the values for the internal variables in this constructor with the values passed in.
Include a __str__ to tell everything about an object of your class, if the object is treated as a string or cast as a string. Include any calculation for the price or value for the object from the numeric variables inside of the string it makes and returns.
Include an __eq__ that checks the numeric values of the object vs another object of its type and tells if they are equal or not (leave out checking the text values to make this easier.)
In main(), create 3 objects of your class with hard coded values and print each of them to show the messages about the objects from their __str__ function. Then compare the first object vs the second object and tell if they are equal in value. [I will change the values to make them equal and not equal in testing to check it.] Change a value on the third one from main using a set() and print it again to show the changed value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started