31 lines
1.0 KiB
Java
31 lines
1.0 KiB
Java
package lab3_abstract_factory.ex2;
|
|
|
|
import lab3_abstract_factory.ex2.car_factories.CoupeFactory;
|
|
import lab3_abstract_factory.ex2.car_factories.MinivanFactory;
|
|
import lab3_abstract_factory.ex2.car_factories.PickupFactory;
|
|
|
|
public class Program {
|
|
public static void main(String[] args) {
|
|
CarCreator coupeCreator = new CarCreator(new CoupeFactory());
|
|
CarCreator minivanCreator = new CarCreator(new MinivanFactory());
|
|
CarCreator pickupCreator = new CarCreator(new PickupFactory());
|
|
|
|
Car c1 = coupeCreator.orderCar("red");
|
|
System.out.println("Car "
|
|
+ c1.getName() + " "
|
|
+ c1.getColor()
|
|
+ " has been ordered.");
|
|
|
|
Car c2 = minivanCreator.orderCar("blue");
|
|
System.out.println("Car "
|
|
+ c2.getName() + " "
|
|
+ c2.getColor()
|
|
+ " has been ordered.");
|
|
|
|
Car c3 = pickupCreator.orderCar("green");
|
|
System.out.println("Car "
|
|
+ c3.getName() + " "
|
|
+ c3.getColor()
|
|
+ " has been ordered.");
|
|
}
|
|
} |