abstract class need acces to subclass atribute
- by user1742980
I have a problem with my code.
public abstract class SimplePolygon implements Polygon
{
...
public String toString(){
String str = "Polygon: vertices =";
for(int i = 0;i<varray.length;i++){
str += " ";
str += varray[i];
}
return str;
}
}
public class ArrayPolygon extends SimplePolygon
{
private Vertex2D[] varray;
public ArrayPolygon(Vertex2D[] array){
varray = new Vertex2D[array.length];
if (array == null){}
for(int i = 0;i<array.length;i++){
if (array[i] == null){}
varray[i] = array[i];
}
...
}
Problem is, that i'm not allowed to add any atribute or method to abstract class SimplePolygon, so i'cant properly initialize varray. It could simply be solved with protected atrib in that class, but for some (stupid) reason i'cant do that. Has anybody an idea how to solve it without that? Thanks for all help.