Exemplo n.º 1
0
  public static void main(String[] args) {

    AbstractFactoryI absFact = FactoryProducer.getFactory("color");

    Color color1 = absFact.getColor("green");
    color1.draw();

    AbstractFactoryI absFact2 = FactoryProducer.getFactory("shape");

    Shape shape1 = absFact2.getShape("rhombus");
    shape1.draw();
  }
  public static void main(String[] args) {

    // get class factory
    AbstractFactory classFactory = FactoryProducer.getFactory("CLASSNAME");

    // get an object of Class Software Development
    Class class1 = classFactory.getClass("SOFTWARE DEVELOPMENT");

    // call checkSchedule method of Class Software Development
    class1.checkSchedule();

    // get an object of Class HCI Usability
    Class class2 = classFactory.getClass("HCI USABILITY");

    // call checkSchedule method of Class HCI Usability
    class2.checkSchedule();

    // get an object of Class Capstone
    Class class3 = classFactory.getClass("CAPSTONE");

    // call checkSchedule method of Class Capstone
    class3.checkSchedule();

    // get class time factory
    AbstractFactory classTimeFactory = FactoryProducer.getFactory("CLASSTIME");

    // get an object of Class Time Morning
    ClassTime classTime1 = classTimeFactory.getClassTime("MORNING");

    // call time method of Morning
    classTime1.time();

    // get an object of Class Time Afternoon
    ClassTime classTime2 = classTimeFactory.getClassTime("AFTERNOON");

    // call time method of Afternoon
    classTime2.time();

    // get an object of Class Time Evening
    ClassTime classTime3 = classTimeFactory.getClassTime("EVENING");

    // call time method of Evening
    classTime3.time();
  }
  public static void main(String[] args) {
    // get shape factory
    AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");

    // get an object of Shape Circle
    Shape shape1 = shapeFactory.getShape("CIRCLE");

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

    // get an object of Shape Rectangle
    Shape shape2 = shapeFactory.getShape("RECTANGLE");

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

    // get an object of Shape Square
    Shape shape3 = shapeFactory.getShape("SQUARE");

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

    // get color factory
    AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");

    // get an object of Color Red
    Color color1 = colorFactory.getColor("RED");

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

    // get an object of Color Green
    Color color2 = colorFactory.getColor("Green");

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

    // get an object of Color Blue
    Color color3 = colorFactory.getColor("BLUE");

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