DirtyProgrammer
DirtyProgrammer

Reputation: 21

How to set fields of an abstract class?

I have an abstract class SVGElement. It has three private fields: String fillColor, String strokeColor, String strokeWidth.

I have another class SVGCircleElement which implements SVGElement, SVGCircle has its own fields radius, centerX, and centerY.

I am testing out the SVGCircleElement. I have the following code:

SVGCircleElement circle = new SVGCircleElement();
circle.setCx(40);
circle.setCy(40);
circle.setRadius(50);

How do I set the fields fillColor, strokeColor, and strokeWidth?

Upvotes: 0

Views: 78

Answers (1)

Boann
Boann

Reputation: 50041

Exactly the same way you set fields of any other class. The fact that the class the fields are defined on is abstract has zero bearing on how you set the fields.

In your specific case, do circle.setFillColor("red"); etc, and make sure that either SVGElement or SVGCircleElement provides those public setter methods.

Upvotes: 3

Related Questions