I need to write + operator for polynomials. How can I do that for
(that’s an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
On Thu, Feb 9, 2012 at 1:09 PM, luk malcik [email protected] wrote:
I need to write + operator for polynomials. How can I do that for
(that’s an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
Well, first start with defining the class that represents your
polynomials
…
(with proper tests, on “input” and “output” methods).
When that is done, start defining the ‘==’, ‘+’, ‘*’, … methods
(with proper tests, otherwise you wouldn’t pass if I was your professor)
Doing the polynomial division and “find poles” would be fun to
earn better grades
HTH,
Peter
*** Available for a new project ***
Peter V.
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v
I need to write + operator for polynomials. How can I do that for
(that’s an example, i need for all polynomials!:)) expression (3x^2 +
2x + 2) + (2x^2 + 2x +5)
class Polynomial
…
def + aPolynomial
your stuff
end
…
end