import color.Color;
import factory.AbstractFactory;
import shape.Shape;

/**
 * Reference:
 * This example is largely based on the abstract factory design pattern example form TutorialsPoint
 * http://www.tutorialspoint.com/design_pattern/abstract_factory_pattern.htm
 */
public class AbstractFactoryPatternDemo {
	public static void main(String[] args) {

		//get shape factory
		System.out.println("Get the shape factory.");
		AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");

		//get an object of Shape Circle
		System.out.println("-- Create a circle.");
		Shape shape1 = shapeFactory.getShape("CIRCLE");

		//call draw method of Shape Circle
		shape1.draw();

		//get an object of Shape Rectangle
		System.out.println("-- Create a rectangle.");
		Shape shape2 = shapeFactory.getShape("RECTANGLE");

		//call draw method of Shape Rectangle
		shape2.draw();

		//get an object of Shape Square
		System.out.println("-- Create a square.");
		Shape shape3 = shapeFactory.getShape("SQUARE");

		//call draw method of Shape Square
		shape3.draw();

		//get color factory
		System.out.println();
		System.out.println("Get the color factory.");
		AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");

		//get an object of Color Red
		System.out.println("-- Create a red color.");
		Color color1 = colorFactory.getColor("RED");

		//call fill method of Red
		color1.fill();

		//get an object of Color Green
		System.out.println("-- Create a green color.");
		Color color2 = colorFactory.getColor("Green");

		//call fill method of Green
		color2.fill();

		//get an object of Color Blue
		System.out.println("-- Create a blue color.");
		Color color3 = colorFactory.getColor("BLUE");

		//call fill method of Color Blue
		color3.fill();
	}
}