标签:art system load property rop content print out oid
7.对象的属性可以是另外一个对象或对象的参考 (视频下载) (全部书籍)
通过这种方法可以迅速构建一个比较大的系统。
class Motor {
Light[] lights;
Handle left, right;
KickStart ks;
Motor() {
lights = new Light[2];
lights[0] = new Light();
lights[1] = new Light();
left = new Handle();
right = new Handle();
ks=new KickStart();
}
}
class Handle {
Grip grip;//grip中文是把套的意思
Handle() {
grip = new Grip();
}
void turnLeft() {
System.out.println("左转车把....");
}
}
class Light {
void turnon() {
System.out.println("开灯.....");
}
}
class KickStart {
void kick() {
System.out.println("踹一脚,启动.........");
}
}
class Grip {
void rollup() {
System.out.println("往上转一下把套,发动.........");
}
}
。。。。。。。。。。。。。。。。
详情请见:http://www.mark-to-win.com/index.html?content=JavaBeginner/javaUrl.html&chapter=JavaBeginner/JavaBeginner2_web.html#PropertyIsObjectOrReference
标签:art system load property rop content print out oid
原文地址:https://www.cnblogs.com/mark-to-win/p/9691901.html