Herencia:
Agregacion:
ambos diseños admiten el mismo main()
sin embargo


y ud.?
Código PHP:
class Fruit {
// Return int number of pieces of peel that resulted from the peeling activity.
public int peel() {
return 1;
}
}
class Apple extends Fruit {
}
//main
Apple apple = new Apple();
int pieces = apple.peel();
Código PHP:
class Fruit {
// Return int number of pieces of peel that resulted from the peeling activity.
public int peel() {
return 1;
}
}
class Apple {
private Fruit fruit = new Fruit();
public int peel() {
return fruit.peel();
}
}
//main
Apple apple = new Apple();
int pieces = apple.peel();
ambos diseños admiten el mismo main()
sin embargo



y ud.?




!!!!

Comentario