Java Factory Pattern

Sort by

recency

|

161 Discussions

|

  • + 0 comments

    This looks like a good example of the factory design pattern. Instead of creating objects directly, the factory handles the logic of returning the right type based on input. cbtfturbo

  • + 1 comment

    This FoodFactory problem is a cool way to see polymorphism in action! Just like how Pizza and Cake implement the Food interface, real-life food spots like Wheelock Place offer a mix of options—whether you're craving fast food (pizza, anyone?) or something sweet (dessert time!).

    Speaking of which, Wheelock Place isn’t just another mall—it’s a go-to for quick bites, healthy meals, and everything in between. Maybe the FoodFactory should add a 'Wheelock Place food' option next—instant access to all those delicious choices!

  • + 0 comments

    Here is Java factory pattern solution - https://programmingoneonone.com/hackerrank-java-factory-pattern-problem-solution.html

  • + 0 comments

    //write your code here if(order.equals("cake")){ return new Cake(); }else if(order.equals("pizza")){ return new Pizza(); } return null;

    Just by adding above it'll work with Java8

  • + 0 comments

    //write your code here if(order.equals("cake")){ return new Cake(); }else if(order.equals("pizza")){ return new Pizza(); } return null;

    Just by adding above it'll work with Java8