📄 randomball.java
字号:
// RandomBall.java
public class RandomBall extends Ball
{
public RandomBall (int newX, int newY, int newRadius, int newXMotion, int newYMotion)
{
// call the Ball constructor
super( newX, newY, newRadius, newXMotion, newYMotion );
}
public void move()
{
// 50% chance of chaning X motion
if( Math.random() > 0.5 )
dx = -dx;
// 50% chance of changing Y motion
if( Math.random() > 0.5 )
dy = -dy;
// move centre of object
x = x + dx;
y = y + dy;
}
} // class RandomBall
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -