package polymorphic;
public class lzi {
public static void main(String[] args) {
peration f=new peration();//操作学生类对象
f.OperatingStudents(new Lee("李四","18","男"));
f.OperatingStudents(new wolf("张三","18","男"));
}
/*
描述计算机14应用技术504班的同学个人信息外 还有其他人的爱好
他们除了学习专业知识 外,还有其他同学的爱好不同\篮球\足球\打游戏\....
1. 李氏
2.张三
3.过一段时间 来了一位新同学
*/
}
class application{//14应用技术504班
String name;//姓名
String Age;//年龄
String Gender;//性别
public application(String name,String Age,String Gender){
this.name=name;
this.Age=Age;
this.Gender=Gender;
}
public final void Study(){
//final 强制这个函数不能复写 因为是:所有学生都学习知识都同样 固定的 !不能改了
System.out.println("姓名:"+name+" "+"年龄:"+Age+" "+"性别:"+ Gender+" "+"学习专业知识");
}
public void Basketbal() {
System.out.println("爱好 打篮球");
}
public void PlayGames(){
System.out.println("爱好 打游戏");
}
public void FootbaLL(){
System.out.println("爱好 踢足球");
}
}
//------------------------------------------
class peration{//操作学生的工具类
public void OperatingStudents(application f){
f.Study();
if(f instanceof Lee){
f.PlayGames();//爱好打游戏
}else if(f instanceof wolf){
f.FootbaLL();//爱好踢足球
}
}
}
class Lee extends application implements Game{
//李氏类继承 14应用技术504班这个类
public Lee(String name, String Age, String Gender) {
super(name, Age, Gender);//访问父类
}
}
class wolf extends application implements Football{
//张三类继承 14应用技术504班这个类
public wolf(String name, String Age, String Gender) {
super(name, Age, Gender);//访问父类的变量
}
}
class NewStudents{
}
//------------爱好 接口扩展学生信息-------------------
interface Basketball{//爱好打篮球
public abstract void Basketbal();
}
interface Game{//爱好打游戏
public abstract void PlayGames();
}
interface Football{//爱好是足球
public abstract void FootbaLL();
}
//------------结束--------------------------------
public class lzi {
public static void main(String[] args) {
peration f=new peration();//操作学生类对象
f.OperatingStudents(new Lee("李四","18","男"));
f.OperatingStudents(new wolf("张三","18","男"));
}
/*
描述计算机14应用技术504班的同学个人信息外 还有其他人的爱好
他们除了学习专业知识 外,还有其他同学的爱好不同\篮球\足球\打游戏\....
1. 李氏
2.张三
3.过一段时间 来了一位新同学
*/
}
class application{//14应用技术504班
String name;//姓名
String Age;//年龄
String Gender;//性别
public application(String name,String Age,String Gender){
this.name=name;
this.Age=Age;
this.Gender=Gender;
}
public final void Study(){
//final 强制这个函数不能复写 因为是:所有学生都学习知识都同样 固定的 !不能改了
System.out.println("姓名:"+name+" "+"年龄:"+Age+" "+"性别:"+ Gender+" "+"学习专业知识");
}
public void Basketbal() {
System.out.println("爱好 打篮球");
}
public void PlayGames(){
System.out.println("爱好 打游戏");
}
public void FootbaLL(){
System.out.println("爱好 踢足球");
}
}
//------------------------------------------
class peration{//操作学生的工具类
public void OperatingStudents(application f){
f.Study();
if(f instanceof Lee){
f.PlayGames();//爱好打游戏
}else if(f instanceof wolf){
f.FootbaLL();//爱好踢足球
}
}
}
class Lee extends application implements Game{
//李氏类继承 14应用技术504班这个类
public Lee(String name, String Age, String Gender) {
super(name, Age, Gender);//访问父类
}
}
class wolf extends application implements Football{
//张三类继承 14应用技术504班这个类
public wolf(String name, String Age, String Gender) {
super(name, Age, Gender);//访问父类的变量
}
}
class NewStudents{
}
//------------爱好 接口扩展学生信息-------------------
interface Basketball{//爱好打篮球
public abstract void Basketbal();
}
interface Game{//爱好打游戏
public abstract void PlayGames();
}
interface Football{//爱好是足球
public abstract void FootbaLL();
}
//------------结束--------------------------------
/*
结果输出;
姓名:李四 年龄:18 性别:男 学习专业知识
爱好 打游戏
姓名:张三 年龄:18 性别:男 学习专业知识
爱好 踢足球
*/