⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randomball.java

📁 Java变的几个小程序
💻 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 + -