Guest User

Untitled

a guest
Apr 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. public class Line {
  2. Point start;
  3. Point end;
  4.  
  5. public Line(Point start, Point end) {
  6. this.start = start;
  7. this.end = end;
  8. }
  9. public String toString() {
  10. return "start: " + start + " end: " + end;
  11. }
  12. public double length(double l) {
  13. l = start.distance(end);
  14. return l;
  15. }
  16. public static void main(String[] args) {
  17. Point p1 = new Point(1, 1);
  18. Point p2 = new Point(4, 4);
  19. Line l1 = new Line(p1, p2);
  20. System.out.println(l1);
  21. System.out.println(l1.length(l));
  22. }
  23. }
Add Comment
Please, Sign In to add comment