Hello everyone ,
I have 2 files , one is Triangle.java and the other is its Main file.
The triangle.java contains methods (functions) , the code
public class Triangle {
Point p1,p2,p3;
public double perimeter() { // Computes the triangle perimeter
// distance between each 2 dots
double d1=Math.sqrt(Math.pow(this.p1.xval-this.p2.xval,2)+Math.pow(this.p1.yval-this.p2.xval,2));
double d2=Math.sqrt(Math.pow(this.p1.xval-this.p3.xval,2)+Math.pow(this.p1.yval-this.p3.yval,2));
double d3=Math.sqrt(Math.pow(this.p3.xval-this.p2.xval,2)+Math.pow(this.p3.yval-this.p2.yval,2));
return (d1+d2+d3);
}
}
Now I'm in the Main file , and I want to calculate the triangle's perimeter
with a given point ,but I don't know how to write it :
public class Main{
Point p1=new Point(1.0,3.5),p2=new Point (2.0,7.3),p3=new Point(1.4,3.9);
/**
System.out.println("The Triangle's perimeter with the points "
+ "(" + p1.getX() + "," + p1.getY() + ")"
+ "(" + p2.getX() + "," + p2.getY() + ")"
+ "(" + p3.getX() + "," + p3.getY() + ")" + " is:" );
..........
since the method "perimeter" doesn't has any given parameters (the lecturer's instructions).any hints ? thanks in advance !