Hi, I was trying to understand how to clone() objects e.g. a point in a cartesian pane, and how to recast them from type "clone" to type "point".
I have a question about the general use and applicability of "recast".
Here are the Java classes, first I created an abstract class for re-use by all sorts of shapes downstream:
... then I created a Point class inheriting from the abstracted super class:
QUESTION: going forward, is this how I can always recast one object to another e.g. from a cloned object to a point on an x-y pane, a circle etc ?
I have never seen where an object is copied as a Class of type clone before. I've seen clone as a method in many classes and have implemented clone() in several of my own, clone() usually refers to making an exact copy of the object you currently have, so setting any properties as the object values you are cloning. If I have a Point (X, Y) where X=128 and Y=200, my clone() of my Point object would give me a new Point (X, Y) where X=128 and Y=200.