📄 ding.java
字号:
/**
*声明:1、本程序是作为金鹰教育网学习Java基本语法的例子。可以自由使用,但必须保留此声明!
* 2、具体的介绍、说明文档,请见金鹰教育网:www.eagledu.org
* 3、有问题的,请到金鹰教育网:www.eagledu.org中的Java标准版本课程中提出,我们会及时给予答复!
* 4、有其它想法的,也可直接交流:eagleduorg@126.com
*/
import java.awt.*;
//丁型图形类
class Ding extends BaseShape
{
private Color dingColor=new Color(245,126,105);// 红
public Ding()//构造函数
{
for(int i=0;i<4;i++)
{
pane[i]=new Pane(dingColor);
}
defaultRotate();
}
//默认的丁型各个方格的位置
protected void defaultRotate()
{
pane[0].setPlace(xpos,ypos);
for(int i=1;i<4;i++)
{
pane[i].setPlace(xpos+(i-2)*20,ypos+20);
}
}
//第一次旋转后各个方格的位置
protected void firstRotate()
{
for(int i=0;i<3;i++)
{
pane[i].setPlace(xpos,ypos+i*20);
}
pane[3].setPlace(xpos+20,ypos+20);
}
//第二次旋转后各个方格的位置
protected void secondRotate()
{
for(int i=0;i<3;i++)
{
pane[i].setPlace(xpos+(i-1)*20,ypos);
}
pane[3].setPlace(xpos,ypos+20);
}
//第三次旋转后各个方格的位置
protected void thirdRotate()
{
for(int i=0;i<3;i++)
{
pane[i].setPlace(xpos,ypos+i*20);
}
pane[3].setPlace(xpos-20,ypos+20);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -