You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
779 B

public class ExerciseRunner {
public static void main(String[] args) {
Factory factory = new Factory();
ConcreteProductA productA = factory.createProduct("A");
if (productA != null) {
productA.showDetails();
} else {
System.out.println("Invalid product type");
}
ConcreteProductA productB = factory.createProduct("B");
if (productB != null) {
productB.showDetails();
} else {
System.out.println("Invalid product type");
}
Object invalidProduct = factory.createProduct("C");
if (invalidProduct != null) {
invalidProduct.showDetails();
} else {
System.out.println("Invalid product type");
}
}
}