[code=java]
public class LineSeg{

  // these are the attributes of a LineSeg object
  private Point end1;
  private Point end2;
  private double length;

    // the constructor
    public LineSeg(double x1, double y1, double x2, double y2) {

        end1 = new Point(x1,y1);
        end2 = new Point(x2,y2);
        this.length=(double)(Math.sqrt((x2-x1)**2+(y2-y1)**2));
     }  
 }

Recommended Answers

All 4 Replies

cant think of anything to make it work continuously giving the same error

You have to many * in this.length=(double)(Math.sqrt((x2-x1)**2+(y2-y1)**2));

There's no "**" operator in Java. Either use Math.pow or write your own squaring function.

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.