mercredi 16 décembre 2015

Java Factory Pattern clarification

If someone can explain me a bit about Factory Pattern. Lets say i have Shape interface (common example on the web). And that Shape has a draw method:

public interface Shape {

    void draw (Graphics g);
}

Now every shape will also have X and Y position also height and width. So I need to declare those methods in my Shape interface like:

public interface Shape {

    void draw (Graphics g);

    void setX1(int x1);

    void setX2(int x1);

    void setY1(int x1);

    void setY2(int x1);
}

so i can call them latter. Am I right about this or this is a bad rookie mistake?

Aucun commentaire:

Enregistrer un commentaire