Skip to content

Instantly share code, notes, and snippets.

@mirsahib
Created January 7, 2017 14:09
Show Gist options
  • Save mirsahib/0da4926bf2d27cd7f22de455889facb9 to your computer and use it in GitHub Desktop.
Save mirsahib/0da4926bf2d27cd7f22de455889facb9 to your computer and use it in GitHub Desktop.
class point2d {
private float x;
private float y;
public point2d(){
this.x=0;
this.y=0;
}
public point2d(float x,float y){
this.x=x;
this.y=y;
}
public float getX(){
return this.x;
}
public float getY(){
return this.y;
}
public float [] getXY(){
float a[]={this.x,this.y};
return a;
}
public void setX(float x){
this.x=x;
}
public void setY(float y){
this.y=y;
}
public void setXY(float x,float y){
this.x=x;
this.y=y;
}
public String toString(){
return "("+this.x+","+this.y+")";
}
}
class Movable_point extends point2d {
private float xSpeed;
private float ySpeed;
public Movable_point(float x,float y,float xSpeed,float ySpeed){
super(x,y);
this.xSpeed=xSpeed;
this.ySpeed=ySpeed;
}
public Movable_point(float xSpeed,float ySpeed){
super();
this.xSpeed=xSpeed;
this.ySpeed=ySpeed;
}
public Movable_point(){
super();
this.xSpeed=0;
this.ySpeed=0;
}
public float getXspeed(){
return this.xSpeed;
}
public float getYspeed(){
return this.ySpeed;
}
public void setXspeed(float xSpeed){
this.xSpeed=xSpeed;
}
public void setYspeed(float ySpeed){
this.ySpeed=ySpeed;
}
public void setSpeed(float xSpeed,float ySpeed){
this.xSpeed=xSpeed;
this.ySpeed=ySpeed;
}
public float[] getSpeed(){
float a[]={this.xSpeed,this.ySpeed};
return a;
}
public Movable_point move(){
//implement move
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment