Guten Tag,
ich habe folgendes Problem, ich hab die Klasse Punkt und Linie und möchte die x und y der Klasse Punkt in Klasse Linie aufrufen nur weiß ich leider nicht wie das geht. Hab schon viel probiert und gegoogelt aber finde nicht wirklich was.
Ich kriege in der Klasse Linie bei der public void darstellen bei x und y eine Fehlermeldung: incompatible types: Punkt cannot be converted to int
[CODE lang="java" title="Punkt"]
public class Punkt{
private int x;
private int y;
public Punkt(int x, int y){
this.x = x;
this.y = y;
}
public void setX(int x){
this.x = x;
}
public int getX(){
return x;
}
public void setY(int y){
this.y = y;
}
public int getY(){
return y;
}
public void darstellen(Interaktionsbrett ib){
ib.neueLinie(x,y,x,y);
}
}
[/CODE]
[CODE lang="java" title="Linie"]
public class Linie{
Punkt punkt;
private Punkt x;
private Punkt y;
private int x2;
private int y2;
public Linie(Punkt x, Punkt y){
this.x = x;
this.y = y;
}
/*
public void setX(int x){
this.x = x;
}
public int getX(){
return x;
}
public void setY(int y){
this.y = y;
}
public int getY(){
return y;
}
*/
public void setX2(int x2){
this.x2 = x2;
}
public int getX2(){
return x2;
}
public void setY2(int y2){
this.y2 = y2;
}
public int getY2(){
return y2;
}
public void darstellen(Interaktionsbrett ib){
ib.neueLinie(x,y,x2,y2);
}
}
[/CODE]
ich habe folgendes Problem, ich hab die Klasse Punkt und Linie und möchte die x und y der Klasse Punkt in Klasse Linie aufrufen nur weiß ich leider nicht wie das geht. Hab schon viel probiert und gegoogelt aber finde nicht wirklich was.
Ich kriege in der Klasse Linie bei der public void darstellen bei x und y eine Fehlermeldung: incompatible types: Punkt cannot be converted to int
[CODE lang="java" title="Punkt"]
public class Punkt{
private int x;
private int y;
public Punkt(int x, int y){
this.x = x;
this.y = y;
}
public void setX(int x){
this.x = x;
}
public int getX(){
return x;
}
public void setY(int y){
this.y = y;
}
public int getY(){
return y;
}
public void darstellen(Interaktionsbrett ib){
ib.neueLinie(x,y,x,y);
}
}
[/CODE]
[CODE lang="java" title="Linie"]
public class Linie{
Punkt punkt;
private Punkt x;
private Punkt y;
private int x2;
private int y2;
public Linie(Punkt x, Punkt y){
this.x = x;
this.y = y;
}
/*
public void setX(int x){
this.x = x;
}
public int getX(){
return x;
}
public void setY(int y){
this.y = y;
}
public int getY(){
return y;
}
*/
public void setX2(int x2){
this.x2 = x2;
}
public int getX2(){
return x2;
}
public void setY2(int y2){
this.y2 = y2;
}
public int getY2(){
return y2;
}
public void darstellen(Interaktionsbrett ib){
ib.neueLinie(x,y,x2,y2);
}
}
[/CODE]