Click here to Skip to main content
15,562,816 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Posted
Updated 5-Sep-22 10:31am
v2
Comments
CPallini 5-Sep-22 13:50pm    
Try harder, show us your code, we might help you completing it.
#ODSDOMS 5-Sep-22 15:22pm    
I don't know object-oriented programming, frankly, and this is the first assignment required of me
Dave Kreskowiak 5-Sep-22 18:19pm    
Then you're in the wrong class. You might want to talk to the instructor to find the right class for you.

1 solution

Quote:
I don't know object-oriented programming
Well you will not complete this assignment without some learning materials. Try The Python Tutorial — Python 3.10.6 documentation[^].
 
Share this answer
 
Comments
#ODSDOMS 5-Sep-22 15:41pm    
can you help me to write the code and i will learn what you will write ???
Richard MacCutchan 5-Sep-22 16:07pm    
I have a better idea. Go to the link I gave you and learn all you need.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900