package com.lovecoding.day09.duotai02;

public class TestReturn {
    public static void main(String[] args) {

        TestReturn testReturn = new TestReturn();

        Pet cat = testReturn.adopt("猫");
        System.out.println(cat);

    }

    public Pet adopt(String name){

        switch (name){
            case "猫":
                Cat cat = new Cat();
                cat.setName("小猫");
                return cat;
            case "狗":
                Dog dog = new Dog();
                dog.setName("效果");
                return dog;
        }
        return null;
    }

}
