Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package domein;
  7.  
  8. /**
  9. *
  10. * @author Gebruiker
  11. */
  12. public class DuckFactory {
  13.  
  14. public static Duck createDuck(String type) {
  15. Duck duck;
  16. switch (type.toLowerCase()) {
  17. case "redheadduck":
  18. duck = new RedheadDuck(new Quack(), new FlyWithWings()); break;
  19. case "mallardduck":
  20. duck = new MallardDuck(new Quack(), new FlyWithWings());break;
  21. case "rubberduck":
  22. duck = new RubberDuck(new Squeak(), new FlyNoWay());break;
  23. case "decoyduck":
  24. duck = new DecoyDuck(new MuteQuack(), new FlyNoWay());break;
  25. default:
  26. duck = null;
  27. }
  28. return duck;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement