2018-04-11

list.add(1);public class Dog{

Dog dog=new Dog(“a”);  Dog dog1=new Dog(“b”);Dog dog2=new Dog(“c”);                    list.add(dog);list.add(dog1);                            //集合的遍历                            for (int i =0; i<list.size(); i++){                        Dog d=list.gte(i);              d.eat();        int x,y,d;    //设置小球颜色    Color ballColor;    //构造方法初始化属性      public  Ball(int x,int y,int d,Color  ball    super() ;  this.x=x;  this.y=y;this.d=d;  this.ballColor =ballColor;  }  //创建小球对象    public  MballJPanel(){    //添加小球的方法    public void addBall(){  int x=(int)  (Math.random()*750);int y=(int) (Math.random()*550);int d=(int) (Math.random()*50+1);int r=(int) (Math.random()*255);        Color  baColor=new Color(r.g. b);  Ball  ball =new Ball(x,y,d,baColor);    balls.add(ball);

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容