Skip to content

Instantly share code, notes, and snippets.

@arjunsk
Created August 17, 2018 18:25
Show Gist options
  • Save arjunsk/b82d0fb55ac79e104e7d64c036e5abc5 to your computer and use it in GitHub Desktop.
Save arjunsk/b82d0fb55ac79e104e7d64c036e5abc5 to your computer and use it in GitHub Desktop.
package solver;
import products.DotMatrixPrinter;
import products.IPrinter;
import products.InkjetPrinter;
import products.LaserPrinter;
public class PrinterFactory {
public static IPrinter createPrinterInstance(String type){
if(type.equalsIgnoreCase("INKJET"))
return new InkjetPrinter();
else if(type.equalsIgnoreCase("DOTMATRIX"))
return new DotMatrixPrinter();
else if(type.equalsIgnoreCase("LASER"))
return new LaserPrinter();
else
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment