package com.lovecoding.day09.duotai04;

public class TestVirtualMethod {
    public static void main(String[] args) {
        //父类           子类
        MyClass my = new MySub();
        Father f = new Father();
        Son s = new Son();
        Daughter d = new Daughter();

        my.method(f);//sub--father

        my.method(s);//son

        my.method(d);//sub--father

    }
}
class MyClass{

    public void method(Father f) {
        System.out.println("father");
    }
    public void method(Son s) {
        System.out.println("son");
    }
}
class MySub extends MyClass{

    @Override
    public void method(Father d) {
        System.out.println("sub--father");
    }

    public void method(Daughter d) {
        System.out.println("daughter");
    }
}
class Father{

}
class Son extends Father{

}
class Daughter extends Father{

}