📄 circle.java
字号:
public class Circle {
private int x, y, radius=10, step=5, side=400;
private boolean clockwise=true;
private double prob;
public Circle(int i, double p) {
x=(i*2*radius)+radius;
y=radius;
prob=p;
}
public void move () {//Complete this code
int intx=radius,inty=radius,height=400-4*radius,width=400-2*radius;
if (clockwise)
{
if ((y==radius)&&(x<width))
{
x=x+5;
if (x>width)
{x=width;
//y=(i*2*radius)+radius;
y=y+5;
}
}
if ((x==width)&&(y<height))
{
y=y+5;
if (y>height)
{
y=height;
x=x-5;
}
}
if ((y==height)&&(x>radius))
{
x=x-5;
if (x<radius)
{
x=radius;
y=y-5;
}
}
if ((x==radius)&&(y>radius))
{
y=y-5;
if (y<radius)
{
y=radius;
x=x+5;
}
}
double rnd = Math.random();
if (rnd<prob) clockwise=false;
}
else
{
//clockwise=false;
if ((y==radius)&&(x>radius))
{
x=x-5;
if (x<radius)
{x=radius;
//y=(i*2*radius)+radius;
y=y+5;
}
}
if ((x==radius)&&(y<height))
{
y=y+5;
if (y>height)
{
y=height;
x=x+5;
}
}
if ((y==height)&&(x<width))
{
x=x+5;
if (x>width)
{
x=width;
y=y-5;
}
}
if ((x==width)&&(y>radius))
{
y=y-5;
if (y<radius)
{
y=radius;
x=x-5;
}
}
}
}
//These are used for drawing circles and must not be changed.
public int getX() {return x;}
public int getY() {return y;}
public int getRadius() {return radius;}
public boolean clockwise() {return clockwise;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -