docs: change the main file to be aling with the subject

This commit is contained in:
amin 2024-07-11 16:28:51 +01:00 committed by zanninso
parent a9a53977e9
commit 6f4f10e010
1 changed files with 14 additions and 1 deletions

View File

@ -2,7 +2,20 @@ public class ExerciseRunner {
public static void main(String[] args) {
Factory factory = new Factory();
// Handle invalid product type
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();