文件名称:zuoye4
介绍说明--下载内容来自于网络,使用问题请自行百度
(1)编写主人类(Master),添加不同的方法,根据输入的宠物类型不同,为不同的宠物看病。编写测试类验证;
(2)使用多态修改代码,为各宠物类添加看病的方法,主人类中保留一个为宠物看病方法即可,参数类型为宠物类类型。编写测试类验证输出效果如图所示。(注意:同一个引用类型,使用不同的实例而执行不同操作就是多态;方法重写是实现多态的基础)((1) write Master class and add different methods to treat different pets depending on the type of pet input. Write test class validation;
(2) use polymorphism to modify the code to add the method for each pet class. In the host class, a pet method can be retained, and the parameter type is pet type. Write the test class verification output effect as shown. (note: the same reference type, using different instances to perform different operations is polymorphism; Method rewriting is the foundation of polymorphism.)
(2)使用多态修改代码,为各宠物类添加看病的方法,主人类中保留一个为宠物看病方法即可,参数类型为宠物类类型。编写测试类验证输出效果如图所示。(注意:同一个引用类型,使用不同的实例而执行不同操作就是多态;方法重写是实现多态的基础)((1) write Master class and add different methods to treat different pets depending on the type of pet input. Write test class validation;
(2) use polymorphism to modify the code to add the method for each pet class. In the host class, a pet method can be retained, and the parameter type is pet type. Write the test class verification output effect as shown. (note: the same reference type, using different instances to perform different operations is polymorphism; Method rewriting is the foundation of polymorphism.)
相关搜索: java
(系统自动生成,下载前可以参看下载内容)
下载文件列表
zuoye4/
zuoye4/.classpath
zuoye4/.project
zuoye4/.settings/
zuoye4/.settings/org.eclipse.jdt.core.prefs
zuoye4/bin/
zuoye4/bin/Person/
zuoye4/bin/Person/demo1.class
zuoye4/src/
zuoye4/src/Person/
zuoye4/src/Person/demo1.java
zuoye4/.classpath
zuoye4/.project
zuoye4/.settings/
zuoye4/.settings/org.eclipse.jdt.core.prefs
zuoye4/bin/
zuoye4/bin/Person/
zuoye4/bin/Person/demo1.class
zuoye4/src/
zuoye4/src/Person/
zuoye4/src/Person/demo1.java
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.