I have created a Triangle class program, but I need a tester class for it. In the tester class, it must ask the user to input the points, and then it would calculate the sides and so fourth. How do I ask the user to input x1 and y1 in the tester, and then get that data in the triangle class? BTW I need to use Scanner for this.
import java.util.Scanner;
public class Triangle {
private double x1;
private double y1;
private double x2;
private double y2;
private double x3;
private double y3;
private double side1;
private double side2;
private double side3;
private double angleA;
private double angleB;
private double angleC;
public Triangle(double a1, double a2, double b1, double b2, double c1, double c2){
x1=a1;
y1=a2;
x2=b1;
y2=b2;
x3=c1;
y3=c2;
}
public double getSide1(){
side1 = Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1,2));
return side1;
}
public double getSide2(){
side2 = Math.sqrt(Math.pow(x3-x2,2)+Math.pow(y3-y2,2));
return side2;
}
public double getSide3(){
side3 = Math.sqrt(Math.pow(x3-x1,2)+Math.pow(y3-y1,2));
return side3;
}
public double getAngleA(){
angleA = side1 + side2 + side3 - (side2 * side3);
return angleA;
}
public double getAngleB(){
angleB = side2 + side1 + side3 - (side1 * side3);
return angleA;
}
public double getAngleC(){
angleC = side3 + side1 + side2 - (side1 * side2);
return angleA;
}
}