java实现宠物商店(查找宠物,添加宠物功能).md

【java实现宠物商店(查找宠物,添加宠物功能).md】代码如图:
主要是练习一下对象的多态和接口的使

interface Pet{ public String getName(); public String getColor(); public int getAge(); } class Cat implements Pet{ private String name; private String color; private int age; public Cat(String name,String color,int age) { this.name=name; this.color=color; this.age= age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } class Dog implements Pet{ private String name; private String color; private int age; public Dog(String name,String color,int age) { this.name=name; this.color=color; this.age= age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } class PetShop{ private Pet[] petArray; private int foot; public PetShop(int len) { if(len>0) this.petArray= new Pet[len]; else this.petArray=new Pet[1]; } public Pet[] getPetArray() { return petArray; } public void setPetArray(Pet[] petArray) { this.petArray = petArray; } public int getFoot() { return foot; } public void setFoot(int foot) { this.foot = foot; } public void addPet(Pet pet) { if(foot

    推荐阅读