Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Triangle {
- Point a;
- Point b;
- Point c;
- public Triangle(Point a, Point b, Point c) {
- this.a = a;
- this.b = b;
- this.c = c;
- }
- public String toString() {
- return "Dreieck mit den Punkten: " + a + ", " + b + ", " + c;
- }
- public double perimeter(Triangle t) {
- double u = a.distance(b) + b.distance(c) + c.distance(a);
- return u;
- }
- public static void main(String[] args) {
- Point p1 = new Point(1, 1);
- Point p2 = new Point(2, 2);
- Point p3 = new Point(1, 3);
- Triangle t1 = new Triangle(p1, p2, p3);
- System.out.println(t1);
- System.out.println(t1.perimeter());
- }
- }
Add Comment
Please, Sign In to add comment