Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. class MySubLine extends MyPoint {
  2. public MyPoint startpt,endpt;
  3.  
  4. public MySubLine() {
  5. this.startpt = new MyPoint();
  6. this.endpt = new MyPoint();
  7. }
  8.  
  9. public MySubLine(int x1,int y1,int x2,int y2) {
  10. this.startpt=new MyPoint(x1,y1);
  11. this.endpt=new MyPoint(x2,y2);
  12. }
  13.  
  14. public MySubLine(MyPoint firstPoint, MyPoint secondPoint) {
  15. this.startpt = firstPoint;
  16. this.endpt = secondPoint;
  17. }
  18.  
  19. public MyPoint getStartPt() {
  20. return startpt;
  21. }
  22.  
  23. public MyPoint getEndPt() {
  24. return endpt;
  25. }
  26.  
  27. public void setEndPt(MyPoint endpt){
  28. this.endpt = new MyPoint(x,y);
  29. }
  30.  
  31. public void setStartPt(MyPoint startpt){
  32. this.startpt = new MyPoint(x,y);
  33. }
  34. public double getLength() {
  35. return Math.abs(Math.sqrt(((startpt.x-endpt.x)*(startpt.x-endpt.x))+((startpt.y-endpt.y)*(startpt.y-endpt.y))));
  36. }
  37.  
  38. public String toString() {
  39. return("("+this.startpt.x+", "+this.startpt.y+") to ("+this.endpt.x+", "+this.endpt.y+")");
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement