Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package domein;
- /**
- *
- * @author Gebruiker
- */
- public class DuckFactory {
- public static Duck createDuck(String type) {
- Duck duck;
- switch (type.toLowerCase()) {
- case "redheadduck":
- duck = new RedheadDuck(new Quack(), new FlyWithWings()); break;
- case "mallardduck":
- duck = new MallardDuck(new Quack(), new FlyWithWings());break;
- case "rubberduck":
- duck = new RubberDuck(new Squeak(), new FlyNoWay());break;
- case "decoyduck":
- duck = new DecoyDuck(new MuteQuack(), new FlyNoWay());break;
- default:
- duck = null;
- }
- return duck;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement