könnt ihr mir helfen
hab also die klasse point und darauf soll ich zugreifen um paar methoden auszusführen
nun ist mein problem ob mein code richtig ist??
hier ist mein code
hab also die klasse point und darauf soll ich zugreifen um paar methoden auszusführen
nun ist mein problem ob mein code richtig ist??
hier ist mein code
Java:
import java.awt.Point;
public class Rhomboid {
// Variablen
private Point pointA;
private Point pointB;
private Point pointC;
private Point pointD; // braucht man eigentlich nicht für diese aufgabe
double umfang;
double flaeche;
// Konstruktor
public Rhomboid(Point pointA, Point pointB, Point pointC, Point pointD) {
super();
this.pointA = pointA;
this.pointB = pointB;
this.pointC = pointC;
this.pointD = pointD;
}
//main methode
public static void main(String[] args) {
Rhomboid r = new Rhomboid(new Point(1,1), new Point(2,2), new Point(3,3)
new Point(4,4));
}
//um das Parallelogramm um den Ursprung zu rotieren
point.rotate(Point center, double angle); // wird aus der klasse point geholt
// brauch ich das?? ist genau das was in der methode in der klasse point steht
void rotate(Point center, double angle) {
this.shift(-center.x, -center.y);
this.rotate(angle);
this.shift(center.x, center.y);
}
// um das Parallelogramm um einen bel. Punkt zu rotieren
point.rotate(double angle)
//brauche ich das??
void rotate(double angle) {
double phi = Math.toRadians(angle);
double xOld = this.x;
double yOld = this.y;
this.x = xOld * Math.cos(phi) - yOld * Math.sin(phi);
this.y = xOld * Math.sin(phi) + yOld * Math.cos(phi);
}
// um den Schwerpunkt zu berechnen
// Umfang zu berechnen
umfang = ((pointA * pointB) + (pointA * pointD)) /2
System.out.println(Umfang);
// Flächeninhalt zu berechnen
flaeche = 1/4 * //
}
Zuletzt bearbeitet von einem Moderator: