Hello, i have to create a java program that calculates a polynomial, kinda. the key question i have is i dont understand what this is asking me right here, and if i am understanding it right, why is it not working? this is what it is asking me

Create a constructor that takes three parameters of type MyDouble representing coefficients a, b, and c (in that order) for the Polynomial being constructed. The data members a, b, and c are to be initialized with these values resulting in the polynomial: "a*x^2 + b*x + c".

this is what i have understood so far, though it gives me an error

public class Polynomial {
	private final MyDouble a;
	private final MyDouble b;
	private final MyDouble c;
	
	public Polynomial (double tempA, double tempB, double tempC){
		
	}
}

i realize there is nothing inside the constructor, but im not exactly sure what to put inside. and without putting anything inside, i get an error that says "The blank final field c may not have been initialized" Thank You for your help!

You'd have to declare the constructor of Polynomial as taking type MyDouble, not type double as you have it declared now. Then you would have to set "a = tempA" and so on. Also, can you post your MyDouble class?

i cant directly post the myDouble class right now, but about that, it seems to have worked, but as i was looking at the javadoc, does it not conflict with what this says?

Constructor Summary
MyDouble(double d)
Initializes the new MyDouble object so that it represents the value of the parameter.
MyDouble(MyDouble m)
Copy Constructor.

i just want to make sure. am i supposed to use

this

in some way shape or form? other than that, your suggestion worked perfectly, it led me to this

public Polynomial (MyDouble tempA, MyDouble tempB, MyDouble tempC){
		a = tempA;
		b = tempB;
		c = tempC;
	}

i just want to check if that makes it a copy constructor or initializing the a as typeA, etc. thank you again, really appreciate it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.