展开全部
public class TestFruitBox {
public static void main(String[] args) {
e68a8462616964757a686964616f31333361323533FruitBox box = new FruitBox(10);
Fruit fruit1 = new Apple("apple", 2.0, "red");
int result = box.addFruit(fruit1);
box.display(0);
// add some more what you want test!
}
}
class FruitBox {
private Fruit fruits[];
private int len;
private int point = 0;
public FruitBox() {
this.len = 100;
fruits = new Fruit[len];
}
public FruitBox(int boxsize) {
this.len = boxsize;
fruits = new Fruit[len];
}
/**
*
* @param fruit
*/
protected int addFruit(Fruit fruit) {
if (point
fruits[point] = fruit;