4、ements Fruit{//通过implements实现接口Fruit private int treeAge; public void grow(){ log("Apple is growing"); } public void harvest(){ log("Apple has been harvested"); } public void plant(){ log("Apple ha been planted"); } public static voi
5、d log(String msg){ System.out.println(msg); } public int getTreeAge(){ return treeAge; } public void setTreeAge(int treeAge){ this.treeAge=treeAge; }}同理,葡萄 Grape:package fac;public class Grape implements Fruit{ private boolean seedless; public
6、void grow(){ log("Grape is growing."); } public void harvest(){ log("Grape has been harvested"); } public void plant(){ log("Grape ha been planted"); } public static void log(String msg){ System.out.println(msg); } public boolean
7、isSeedless() { return seedless; } public void setSeedless(boolean seedless) { this.seedless = seedless; } }草莓 Stuawberry:package fac;public class Strawberry implements Fruit{ public void grow(){ log("