I am using Eclipse IDE. I have created a class called LineSegment. I have to implement this class in my program I am writing called LineSegmentTesterApp.

However, when trying to use the accessor method getX1, getX2, getY1, etc... I get an error saying that the method is undefined. I think I may be looking over something. Thanks in advance for th help. P.s. my first time having to create and implement my own class.

Code java:

package linesegmentapp; /** * File: LineSegment.java * @author Jarrod Rotolo * Purpose: This class describes a line segment * Date: March 6, 2012 * Course: CSC 1350 */ public class LineSegment { /** * The X coordinate of the start point of the line segment. */ private double x1; /** * The X coordinate of the end point of the line segment. */ private double x2; /** * The Y coordinate of the start point of the line segment. */ private double y1; /** * The Y coordinate of the end point of the line segment. */ private double y2; /** * Constructs and initializes a Line with coordinates (0,0)->(0,0). */ public LineSegment() { x1 = 0; y1 = 0; x2 = 0; y2 = 0; } /** * Constructs and initializes a Line2D from the specified coordinates. * @param x1Val - the X coordinate of the start point * @param y1Val - the Y coordinate of the start point * @param x2Val - the X coordinate of the end point * @param y2Val - the Y coordinate of the end point */ public LineSegment(double x1Val, double y1Val, double x2Val, double y2Val) { x1 = x1Val; y1 = y1Val; x2 = x2Val; y2 = y2Val; } /** * Returns the X coordinate of the start point in double precision. * @return the X coordinate of the start point in double precision. */ public double getX1() { return x1; } /** * Returns the X coordinate of the end point in double precision. * @return the X coordinate of the end point in double precision. */ public double getX2() { return x2; } /** * Returns the Y coordinate of the start point in double precision. * @return the Y coordinate of the start point in double precision. */ public double getY1() { return y1; } /** * Returns the Y coordinate of the end point in double precision. * @return the Y coordinate of the end point tin double precision. */ public double getY2() { return y2; } /** * Computes the length of this line segment. * @return the length of this line segment */ public double length() { return Math.sqrt((x2-x1)+(y2-y1)); } /** * Sets the location of the end points of this Line2D to the specified double coordinates. */ public void setLine(double x1Val, double y1Val, double x2Val, double y2Val) { x1 = x1Val; y1 = y1Val; x2 = x2Val; y2 = y2Val; } }

Code java:

package linesegmentapp; /** * File: LineSegmentTester.java * @author Jarrod Rotolo * Purpose: This program creates a triangle using the implemented class LineSegment * Date: March 6, 2012 * Course: CSC 1350 */ import java.util.*; import linesegmentapp.LineSegment; public class LineSegmentTester { public static void main(String[] args) { double x1, x2, x3; double y1, y2, y3; Scanner keyb = new Scanner(System.in); System.out.println("Enter the x- and y- coordinates of the first point> "); x1 = keyb.nextDouble(); y1 = keyb.nextDouble(); System.out.println("Enter the x- and y- coordinates of the second point> "); x2 = keyb.nextDouble(); y2 = keyb.nextDouble(); System.out.println("Enter the x- and y- coordinates of the third point> "); x3 = keyb.nextDouble(); y3 = keyb.nextDouble(); LineSegment line1 = new LineSegment(x1,y1,x2,y2); LineSegment line2 = new LineSegment(x2,y2,x3,y3); LineSegment line3 = new LineSegment(x3,y3,x1,y1); System.out.println("The sides of the triangle are"); System.out.println("line 1:[("+getX1()+","+getY1()+")->("+getX2()+","+getY2()+")]"); System.out.println("line 2:[("+getX2()+","+getY2()+")->("+getX3()+","+getY3()+")]"); System.out.println("line 3:[("+getX3()+","+getY3()+")->("+getX1()+","+getY1()+")]"); double perimeter = line1.length() + line2.length() + line3.length(); double s = perimeter/2; double area = Math.sqrt(s*(s-line1.length())*(s-line2.length())*(s-line3.length())); } }