предположим, у меня есть следующий родительский класс и два дочерних класса, каждый дочерний элемент добавляет новый параметр к параметрам, унаследованным от родителя. Пример
public class Parent {
private int x;
public Parent(int x) {this.x = x;}
public int getX() {return x;}
public void setX(int x) {this.x = x;}
}
Первый ребенок
public class FirstChild extends Parent {
private int y;
public FirstChild(int x, int y) {
super(x);
this.y = y;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
Второй ребенок
public class SecondChild extends Parent{
private int z;
public SecondChild(int x, int z) {
super(x);
this.z = z;
}
public int getZ() {
return z;
}
public void setZ(int z) {
this.z = z;
}
}
так как я могу использовать фабричный метод здесь?,