Hi everybody, I have been having trouble with the output of a set of points for my triangle program. When I run my program, it outputs in the end "triangle1 coordinates: Vertex A is java.awt.Point[x=12,y=13]" and I have no idea how to format it to hide the "java.awt.Point" part. Any advice would be greatly appreciated! Thanks in advance.
public class TriangleTester
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter the x- and y- coordinates of the first vertex: ");
int a1 = scan.nextInt();
int a2 = scan.nextInt();
System.out.println("Enter the x- and y- coordinates of the second vertex: ");
int b1 = scan.nextInt();
int b2 = scan.nextInt();
System.out.println("Enter the x- and y- coordinates of the third vertex: ");
int c1 = scan.nextInt();
int c2 = scan.nextInt();
Triangle triangle1 = new Triangle(a1, a2, b1, b2, c1, c2);
System.out.println(triangle1.toString());
}
}
public class Triangle
{
private int xA;
private int yA;
private int xB;
private int yB;
private int xC;
private int yC;
Point vertexA;
Point vertexB;
Point vertexC;
public Triangle(Point vertexA, Point vertexB, Point vertexC)
{
vertexA = vertexA;
vertexB = vertexB;
vertexC = vertexC;
}
public Triangle(int xA, int yA, int xB, int yB, int xC, int yC)
{
vertexA = new Point(xA, yA);
vertexB = new Point(xB, yB);
vertexC = new Point(xC, yC);
}
public String toString()
{
return "Vertex A is " + vertexA.toString();
}
}