📄 mycircle.java
字号:
package secondpkg;import firstpkg.MyShape;import firstpkg.ShapeElement;import firstpkg.MyPoint;public class MyCircle extends MyShape implements CirclePrintable,firstpkg.ShapeElement{ private static final String m_Introduction="The Class Name is 'MyCircle '"; private MyPoint m_Centre; private int m_Radius; //构造函数是用了方法的重载 public MyCircle() { } public MyCircle(int newX, int newY, int newRadius) { this.m_Centre=new MyPoint(newX,newY); this.m_Radius=newRadius; } public MyCircle(int newX, int newY, int newRadius,String newBackgroundColor,String newForeColor,int newLineBorder) { this.m_Centre=new MyPoint(newX,newY); this.m_Radius=newRadius; this.m_BackGroundColor.setColorString(newBackgroundColor); this.m_ForeColor.setColorString(newForeColor); this.m_LineBroad=newLineBorder; } public double getArea() { return ShapeElement.PAI*this.m_Radius*this.m_Radius; } double getDiameter() { return 2*MyCircle.PAI*this.m_Radius; } int getX() { return this.m_Centre.m_X; } void setX(int newX) { this.m_Centre.m_X=newX; } int getY() { return this.m_Centre.m_Y; } void setY(int newY) { this.m_Centre.m_Y=newY; } int getR() { return this.m_Radius; } void setR(int newR) { this.m_Radius=newR; } public static String getIntroduction() { //can't use this reference!!! return m_Introduction; } public void printR() { System.out.println("The Circle's R is: "+this.m_Radius); } public void printX() { System.out.println("The Circle's X is: "+this.m_Centre.m_X); } public void printY() { System.out.println("The Circle's Y is: "+this.m_Centre.m_Y); } //printBackGroundColor 、printForeColor 和printLineBroad三个成员方法被MyCircle覆盖 public void printBackGroundColor() { System.out.println("The BackGroundColor of MyCircle Object is: "+this.m_BackGroundColor); } public void printForeColor() { System.out.println("The ForeColor of MyCircle Object is: "+this.m_ForeColor); } public void printLineBroad() { System.out.println("The LineBroad of MyCircle Object is: "+this.m_LineBroad); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -