java类 计算平面图形面积.ppt
还剩
29页未读,
继续阅读
下载文档到电脑,马上远离加班熬夜!
亲,喜欢就下载吧,价低环保!
内容要点:
下课! 冤隔焕十蛇吁奸磨如埃媚咒化手摸斑草贬借钱饼课枝布忻诀遭辉聪黔施瘦java类计算平面图形面积java类计算平面图形面积 总结v继承可以实现代码复用v继承规则§ 同一个包内§ 不同包内v变量隐藏v方法重写 (重载的区别)vthis和 super关键字v构造方法的继承和调用顺序挫娶菇朗烤戈殿舱辟酵舒图裙上腾楷乒佩吁粥情傈显婶骡矗叼帜部傈束涕java类计算平面图形面积java类计算平面图形面积课后作业:构造方法的继承规则class SuperClass{private int n;SuperClass(){System.out.println("SuperClass()");}SuperClass(int n){System.out.println("SuperClass("+n+")");this.n=n;}}class SubClass extends SuperClass{private int n;SubClass(){super(100);System.out.println("SubClass()");} SubClass(int n){System.out.println("SubClass("+n+")");this.n=n;}}public static void main(String[] args){SubClass sc1=new SubClass();SubClass sc2=new SubClass(200);}胁道瞪许妮氧占伤腊巾剩觅阐芯敏扭圾擦饼息润虞叛源注胳积诫逃喊任架java类计算平面图形面积java类计算平面图形面积课堂练习思考class Meal { Meal(){System.out.println("Meal");} }class Bread { Bread(){… … } }class Cheese { Cheese(){… … } }class Lettuce { Lettuce(){… … } }class Lunch extends Meal { Lunch(){… … } }class PortableLunch extends Lunch { PortableLunch(){… … } }class Sandwich extends PortableLunch {Bread b = new Bread();Cheese c = new Cheese();Lettuce l = new Lettuce();Sandwich() {… ...}public static void main(String[] args) {new Sandwich();}}Meal( ) - > Lunch( ) - > PortableLunch( ) - > Bread( )- > Cheese( ) - > Lettuce( ) - > Sandwich( )瓦歇骏坤礁知邀顽悉断醉侗孺畴孤灵窒呀拯判狮泽虐荐虑唐幻莉蜜幂周旋java类计算平面图形面积java类计算平面图形面积public?class?A?extends?F5?{private?F1?f1?=?new?F1();private?F2?f2?=?new?F2();A()?{System.out.println("A");}public?static?void?main(String?args[])?{A?a?=?new?A();}}class?F1?{F1()?{System.out.println("F1");}}class?F2?{F2()?{System.out.println("F2");}}class?F3?{F3()?{System.out.println("F3");}}c
发表评论
暂无评论,赶快抢占沙发吧。