Let's say I have two public classes like the ones below:
The oval class which will get the width and height parameters.
public class Oval extends Shape{
OvalClass oval;
public Oval(int width,int height){
oval = new OvalClass("first",10);
}
}
and a Shape class which is supposed to have any different form (that's why I'm extending it).
public class Shape {
public void moveLeft(){
//object?
object.posX += 1;
}
}
EDIT:
We don't know enough about GOval, the other classes, and the move() method to give a good answer.
Consider this other OvalClass
as the oval class:
public class OvalClass {
String name;
int posX;
public OvalClass(String name, int posx){}
}
The thing is, how can I get the object
oval (GOval oval
) created in the Oval in the Shape class?
Is there any better approach?