Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. abstract class Creator{
  2. // Definimos método abstracto
  3. public abstract Product factoryMethod();
  4. }
  5.  
  6. public class ConcreteCreator extends Creator{
  7. public Product factoryMethod() {
  8. return new ConcreteProduct();
  9. }
  10. }
  11.  
  12. public interface Product{
  13. public void operacion();
  14. }
  15.  
  16. public class ConcreteProduct implements Product{
  17. public void operacion(){
  18. System.out.println("Una operación de este producto");
  19. }
  20. }
  21.  
  22. public static void main(String args[]){
  23. Creator aCreator;
  24. aCreator = new ConcreteCreator();
  25. Product producto = aCreator.factoryMethod();
  26. producto.operacion();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement