line.java

来自「第四次作业 1、 创建一个Animal(动物)类」· Java 代码 · 共 41 行

JAVA
41
字号

public class Line extends GraphicObject {
	/**
	 * specific attributes that Line needs
	 */
	private Point origin;
	private Point end;
	
	Line(){
		super();
		origin = new Point(0,0);
		end = new Point(0,1);
	}
	
	Line(Point first,Point last, String color ){
		super(color,"null");
	    origin = first;
		end = last;
	}
		

	@Override
	public void draw() {
		// TODO Auto-generated method stub
		System.out.println("Draw the origin of the line is ("+origin.getX()+","+origin.getY()+").The end is(" +
				end.getX()+","+end.getY()+").color of the line is "+super.getColorOfLine());

	}

	@Override
	public void rotate() {
		// TODO Auto-generated method stub
		System.out.println("rotate this line");
		end.setNewPoint(2*origin.getX()-end.getX(),end.getY() );
		draw();
		

	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?