The class has the following methods:
- A constructor with one tuple argument called coefficients to define and initialize two instant variables, a and b, with default values of 0.
- getCoff method that returns a tuple of coefficients a and b.
- getRoot method that returns the root of equation (root = –b/a).
- isRoot method with one real number argument that checks if a given number is the equation’s root or not. Use getRoot to get the root.
- An overloading method for the str() operator that returns the equation string represented as
a x + b = 0.
- An overloading method for the == operator that returns True only if coefficients, a and b, are the same for both linear objects.
Write a class called quadratic that is derived from linear class to represents a quadratic equation
(c x2 + b x + a = 0). The class has the following methods:
- A constructor with one tuple argument called coefficients assigned to a hidden (private) instant variable, c, and the two linear object attributes, a and b, with default values of 0. Call the super class constructor for a and b variables.
- An overriding method for getCoff method that returns a tuple of coefficients c, b, and a, respectively.
- An overriding method for getRoot that returns a tuple of roots for the quadratic equation
(roots = (–b ± sqrt( b2 – 4ac) ) / 2c ). Use math library.
- An overriding method for isRoot method with one real number argument that checks if a given number is one of the equation’s root or not. Use getRoot to get the roots.
- An overloading method for the str() operator that returns the equation string represented as
c x^2+ b x + a = 0.
What I have tried:
Write a code to create objects/instances of the above-mentioned classes please