Informatiker Board (http://www.informatikerboard.de/board/index.php)
- Themengebiete (http://www.informatikerboard.de/board/board.php?boardid=1)
-- Praktische Informatik (http://www.informatikerboard.de/board/board.php?boardid=6)
--- 3D Punkt u. Quader (http://www.informatikerboard.de/board/thread.php?threadid=2026)


Geschrieben von neuling96 am 27.12.2014 um 04:45:

  3D Punkt u. Quader

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
public class Punkt3D extends Punkt2D{ 
private double zKoordinate;
public Punkt3D(double x, double y, double z) {
super( x,y); 
this.zKooordinate=z;
}
public void verschiebe(double x, double y, double z) {
super.verschiebe(x, y); 
this.zKooordinate += z;
}
public double getZKoordinate() { 
return this.zKoordinate;
}

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
public class Quader {
private Punkt3D eckPunkt;
 private double laengeX; 
private double laengeY; 
private double laengeZ;
public Quader(Punkt3D eckPunkt, double x, double y, double z) {
this.eckPunkt = eckpunkt;
this.laengeX = x;
 this.laengeY = y;
 this.laengeZ = z;
}
public void verschiebe(double x, double y, double z) {
this.eckPunkt.verschiebe(x,y,z);
}
}



Geschrieben von eulerscheZahl am 27.12.2014 um 07:45:

 

Der Punkt3D sieht gut aus.
Der Quader passt auch, alternativ zu den Längen könntest du auch 2 gegenüberliegende Ecken als Punkt3D speichern. Hätte den Vorteil, dass du den Quader leicht in ein Rechteck umwandeln kannst, wenn du einen Punkt2D entgegennimmst (für sowas gibts Templates, aber so weit bist du wohl noch nicht).



Geschrieben von neuling96 am 08.01.2015 um 18:08:

 

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
public class Punkt3D extends Punkt2D{ 
private double zKoordinate;
public Punkt3D(double x, double y, double z) {
super( x,y); 
this.zKooordinate = z;
}
public void verschiebe(double x, double y, double z) {
super.verschiebe(x, y); 
this.zKooordinate += z;
}
public double getZKoordinate() { 
return this.zKoordinate;
}
}


wieso wird z nicht gefunden?



Geschrieben von eulerscheZahl am 08.01.2015 um 19:13:

 

Zähle die 'o', dann weißt du es.



Geschrieben von neuling96 am 08.01.2015 um 19:18:

 

danke Wink


Forensoftware: Burning Board, entwickelt von WoltLab GmbH