Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MySubLine extends MyPoint {
- public MyPoint startpt,endpt;
- public MySubLine() {
- this.startpt = new MyPoint();
- this.endpt = new MyPoint();
- }
- public MySubLine(int x1,int y1,int x2,int y2) {
- this.startpt=new MyPoint(x1,y1);
- this.endpt=new MyPoint(x2,y2);
- }
- public MySubLine(MyPoint firstPoint, MyPoint secondPoint) {
- this.startpt = firstPoint;
- this.endpt = secondPoint;
- }
- public MyPoint getStartPt() {
- return startpt;
- }
- public MyPoint getEndPt() {
- return endpt;
- }
- public void setEndPt(MyPoint endpt){
- this.endpt = new MyPoint(x,y);
- }
- public void setStartPt(MyPoint startpt){
- this.startpt = new MyPoint(x,y);
- }
- public double getLength() {
- return Math.abs(Math.sqrt(((startpt.x-endpt.x)*(startpt.x-endpt.x))+((startpt.y-endpt.y)*(startpt.y-endpt.y))));
- }
- public String toString() {
- return("("+this.startpt.x+", "+this.startpt.y+") to ("+this.endpt.x+", "+this.endpt.y+")");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement