📄 rotatefigure.java
字号:
import dslib.exception.*;
/** A Figure with rotation capabilities */
public class RotateFigure extends Figure
{
/** Constructor for the rotating figure
Analysis : Time = O(1) */
public RotateFigure(String x)
{
super(x);
}
/** Rotate the figure deg degrees counter-clockwise.
Analysis: time = O(number of parts to the figure) */
public void rotate(int deg)
{
parts.goFirst();
while (!parts.after())
{
Shape item = (Shape) parts.item();
if (item instanceof Rectangle)
{
Rectangle c = (Rectangle)item;
/* Code to rotate a rectangle. */
}
else if (item instanceof Circle)
{
Circle r = (Circle)item;
/* Code to rotate a circle. */
}
else if (item instanceof Square)
{
Square s = (Square)item;
/* Code to rotate a square. */
}
parts.goForth();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -