We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Advanced
- Java Factory Pattern
- Discussions
Java Factory Pattern
Java Factory Pattern
Sort by
recency
|
153 Discussions
|
Please Login in order to post a comment
interface Food { public String getType(); } class Pizza implements Food { public String getType() { return "Someone ordered a Fast Food!"; } }
//Write your code here
}//End of getFood method
//Java 15
my Code :
import java.io.; import java.util.;
interface Food {
}
class Cake implements Food{ public String getType(){
}
class Pizza implements Food{ public String getType(){
}
public class Solution {
}
return order.equals("cake") ? new Cake() : new Pizza();
Why on earth teach such bad habits on such a basic question. Where is the use of constants or enum?