Guest User

Untitled

a guest
Apr 26th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public class Triangle {
  2. Point a;
  3. Point b;
  4. Point c;
  5. public Triangle(Point a, Point b, Point c) {
  6. this.a = a;
  7. this.b = b;
  8. this.c = c;
  9. }
  10. public String toString() {
  11. return "Dreieck mit den Punkten: " + a + ", " + b + ", " + c;
  12. }
  13. public double perimeter(Triangle t) {
  14. double u = a.distance(b) + b.distance(c) + c.distance(a);
  15. return u;
  16. }
  17. public static void main(String[] args) {
  18. Point p1 = new Point(1, 1);
  19. Point p2 = new Point(2, 2);
  20. Point p3 = new Point(1, 3);
  21. Triangle t1 = new Triangle(p1, p2, p3);
  22. System.out.println(t1);
  23. System.out.println(t1.perimeter());
  24. }
  25. }
Add Comment
Please, Sign In to add comment