package com.lovecoding.day09.duotai02;

public class TestPet {
    public static void main(String[] args) {
        //声明变量是父类类型，变量赋值子类对象
        Pet pet = new Dog();

        Person p1 = new Person();

        //方法的形参是父类类型，调用方法的实参是子类对象
        Dog dog = new Dog();
        dog.setName("沙皮");
        p1.adopt(dog);

        //实例变量声明父类类型，实际存储的是子类对象

        //属性
        Cat cat = new Cat();
        cat.setName("波斯猫");

        p1.pet = dog; //new Cat();
        p1.showInfo();

    }

}
