myline.java

来自「创建一些形状类」· Java 代码 · 共 79 行

JAVA
79
字号
/*  * File name: MyLine.java * * This file defines a MyLine class. * * Author: R. R. Gargeya * Date:   12 March 2000 * * Distribution: This header should always be included. */import java.awt.Graphics;public class MyLine{    private int x1, y1, x2, y2;    public MyLine()    {	x1 = 0;	y1 = 0;	x2 = 0;	y2 = 0;    }    public MyLine(int x1, int y1, int x2, int y2)    {	this.x1 = x1;	this.y1 = y1;	this.x2 = x2;	this.y2 = y2;    }        public void setX1(int x1)    {	this.x1 = x1;    }    public void setY1(int y1)    {	this.y1 = y1;    }    public void setX2(int x2)    {	this.x2 = x2;    }    public void setY2(int y2)    {	this.y2 = y2;    }    public int getX1()    {	return x1;    }    public int getY1()    {	return y1;    }    public int getX2()    {	return x2;    }    public int getY2()    {	return y2;    }    public void draw(Graphics g)    {	g.drawLine(x1, y1, x2, y2);    }}

⌨️ 快捷键说明

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