abstract public class GeoObj { private int nummer ; abstract public void print() ; abstract public GeoObj verschiebe (int dx, int dy) ; public int getNummer () { return this.nummer ; } } public class Gerade extends GeoObj { private Punkt anfang, ende ; public Gerade () { anfang=new Punkt(0,0); ende=new Punkt(0,0); } public Gerade (Punkt p1, Punkt p2) { anfang=p1; ende=p2; } public Punkt getAnfang () { return this.anfang ; } public Punkt getEnde () { return this.ende ; } public Gerade verschiebe (int dx, int dy) { return new Gerade(anfang.verschiebe(dx,dy),ende.verschiebe(dx,dy)); } public void print() { System.out.println("Gerade von ("+getAnfang().getX()+","+getAnfang().getY()+") nach ("+getEnde().getX()+","+getEnde().getY()+")"); } } public class Kreis extends GeoObj { private Punkt center; private float radius ; public Kreis () { center=new Punkt(0,0); radius=0; } public Kreis (Punkt ctr, float rad) { center=ctr; radius=rad; } public Punkt getCenter () { return this.center ; } public float getRadius () { return this.radius ; } public Kreis verschiebe (int dx, int dy) { return new Kreis(center.verschiebe(dx,dy),this.radius); } public Kreis resize (int dSize) { return new Kreis(this.center,this.radius+dSize); } public void print() { System.out.println("Kreis um ("+getCenter().getX()+","+getCenter().getY()+") mit Radius "+getRadius()); } } public class Punkt extends GeoObj { private float x, y ; static int anzahl = 0 ; public Punkt () { x=0; y=0; nummer=++anzahl; } public Punkt (float x1, float y1) { x=x1; y=y1; nummer=++anzahl; } public float getX () { return this.x ; } public float getY () { return this.y ; } public int getAnzahl () { return anzahl ; } public Punkt verschiebe (int dx, int dy) { return new Punkt(this.x+dx,this.y+dy); } public void print() { System.out.println("Der Punkt ("+getX()+","+getY()+") hat die nummer "+getNummer()+" von "+getAnzahl()); } }