So I’m working through some programming exercises in java right now and the current exercise I’m using involves using the acm.graphics library. Basic shapes and stuff drawing pictures.
What I want to do, is create a function which has parameters for a GObject and a Color object and call setFilled() and setColor appropriately (since retyping this for each shape object is extremely redundant).
The problem I’m running into is this,
The GObject class is a superclass of GRect, GOval, GLine, etc but doesn’t actually contain a setFilled function (thus throwing an error when trying a parameter header such as function f(GOBject A, Color ArgC).
So how should I go about creating this function, or is it even possible without editing the standardized library for GObject. I was thinking I could deal with this error by simply creating an empty setFilled function in GObject but from what I understand its generally a bad idea to go into standardized libraries and make changes arbitrarily and the right approach for making changes should be to extend / overload from a subclass as needed. Anyways I’m at an impasse with my compiler so I’m open to ideas, thanks.
P.S/Nonrelevant Question why is the word “problem” banned from the Title Box?
Write it for the GFillable interface instead since this is implemented by the shapes you are after. http://jtf.acm.org/javadoc/complete/acm/graphics/GFillable.html