public interface Sender{
void send();
}
public class MailSender implements Sender{
@Override
public void send(){
System.out.println("i am mailsender");
}
}
public class SmsSender implements Sender{
@Override
public void send(){
System.out.println("i am smssender");
}
}
public class Provider{
private List<Sender> list = new ArrayList<Sender>();
public void processMailSender(int count){
for(int i=0; i<count; i++){
list.add(new MailSender());
}
}
public void processSmsSender(int count){
for(int i=0; i<count; i++){
list.add(new SmsSender());
}
}
}
public class Test{
public static void main(String[] args){
Provider provider = new Provider();
provider.processMailSender(10);
}
}
public class MailSender implements Sender{
@Override
public void send(){
System.out.println("i am mailsender");
}
}