public interface Brand {
void call();
}
public class Apple implements Brand{
@Override
public void call() {
System.out.println("apple");
}
}
public abstract class Phone {
private final Brand brand;
protected Phone(Brand brand) {
this.brand = brand;
}
void call(){
brand.call();
}
}
public class SplitPhone extends Phone{
protected SplitPhone(Brand brand) {
super(brand);
System.out.println("SplitPhone");
}
}
public class Test {
public static void main(String[] args) {
Brand apple=new Apple();
Phone phone=new SplitPhone(apple);
phone.call();
}
}