la première partie de mon projet est de construire un hypergraphemodèle usine lorsque le produit abstrait est classe générique
Ceci est un rapide-a appelé diagramme UML
Vertex classe
public abstract class Vertex <T>{
int vertexId ;
T vertexValue ;
public abstract T computeVertexValue();
}
Imagevertex Classe
public class ImageVertex extends Vertex<Map<String, Instance>>{
public ImageVertex(int id) {
this.vertexId=id;
}
@Override
public Map<String, Instance> computeVertexValue(){
return null;
}
}
RésuméVertexFactory
public abstract class AbstractVertexFactory {
public abstract Vertex createVertex(int id);
public Vertex produceVertex(int id) {
Vertex vertex = createVertex(id);
vertex.computeVertexValue();
return vertex;
}
}
classe imagefactory
public class ImageFactory extends AbstractVertexFactory {
@Override
public Vertex createVertex(int id) {
// TODO Auto-generated method stub
return new ImageVertex(id);
}
}
Simulator
public class ImageFactorySimulator {
/**
* @param args
*/
public static void main(String[] args) {
AbstractVertexFactory imFactory= new ImageFactory();
ImageVertex im = (ImageVertex) imFactory.createVertex(0);
}
}
l'utilisation de fonte dans le simulateur est boared Comment puis-je éviter?
Non, ce ne compilera pas ce compilera –
Désolé ther était une faute de frappe – Alepac
Ok, mais ne suit plus le modèle de fabrique abstraite. –