I\'m writing code to create an object, clone the object, then compare the two.
The object in question, Octagon, is an extension of an object GeometricObject
You may write a copy-constructor:
public Octagon( Octagon right ){
this.side = right.side;
}
And use it from the clone method:
public Object clone() throws CloneNotSupportedException {
return new Octagon( this );
}
Replace
Octagon copy = (Octagon)test.clone();
with
Octagon copy = (Octagon)((Octagon)test).clone();
so that the called clone method is the one of your class.