Lösungsvorschlag 7.3 - Aufgabe 2
Aus ComeniusWiki
Version vom 9. März 2014, 10:22 Uhr von B.Schiller (Diskussion | Beiträge)
public class Punkt{
//Attribute
private int x;
private int y;
//Konstruktor
public Punkt(int x, int y){
this.x=x;
this.y=y;
}
//Getter- und Setter-Methoden (nur zur Uebung)
public int getX(){
return x;
}
public int y(){
return y;
}
public void setX(int newX){
x=newX;
}
public void setY(int newY){
y=newY;
}
}
public class Kreis{
//Attribute
private int radius;
private Punkt center;
//Konstruktor
public Kreis(int radius, int x, int y){
this.radius = radius;
center = new Punkt(x,y);
}
public void verschieben(int newX, int newY){
center = new Punkt(newX, newY);
}
public void radiusVeraendern(int radNew){
radius=radNew;
}
}

