Write a program to solve the Line problem.

Define a class of objects called Line. Every Line is a pair of two 
Points. A Point is a pair of two numbers (the Lines are also in the 
plane in these exercises). Points should be able to determine their 
distance to other Points (see above). Lines are created by passing 
two Points to the Line constructor. A Line object must be able to 
report its length, which is the distance between its two end points. 
Make length a method and write a test program in which you create a 
few Lines and ask them to report their lengths. 

Here's an example of such a test program and its output.

  frilled.cs.indiana.edu%cat One.java
  class One {
    public static void main(String[] args) {
      Line a = new Line(new Point(0, 0), new Point (1, 1)); 
      System.out.println(a.length()); 
    }
  }
  frilled.cs.indiana.edu%javac One.java
  frilled.cs.indiana.edu%java One
  1.4142135623730951
  frilled.cs.indiana.edu%

Here's my code:

  class Line {
    Point a, b;
    double length() {
      return a.distanceTo(b);
    }
    Line(Point u1, Point u2) {
      this.a = u1;
      this.b = u2;
    }
  }