Class:
Module Product {
Report "A new Product"
}
}
class Creator {
module anOperation {
Report "An Operation of Creator - Use a specific to object factoryMethod"
product = .factoryMethod()
}
function factoryMethod {
Error "Not implemented yet "+module.name$
}
Class:
Module Creator {
Report "A new Creator"
}
}
class ConcreteProduct as Product {
class:
module ConcreteProduct {
\\ call Product module which is part of Product.
.Product
Report "A new ConcreteProduct is a Product"
}
}
class ConcreteProduct2 as Product {
class:
module ConcreteProduct2 {
\\ call Product module which is part of Product.
.Product
Report "A new ConcreteProduct2 is a Product"
}
}
class ConcreteCreator as Creator {
function final factoryMethod {
Print "factoryMethod 001"
=ConcreteProduct()
}
class:
module ConcreteCreator {
.Creator
Report "A new ConcreteCreator is a Creator"
}
}
class ConcreteCreator2 as Creator {
function final factoryMethod {
Print "factoryMethod 002"
=ConcreteProduct2()
}
class:
module ConcreteCreator2 {
.Creator
Report "A new ConcreteCreator2 is a Creator"
}
}
Module Client {
Report 2, "ConcreteCreator attach a new factoryMethod to a creator class"
creator = ConcreteCreator()
creator.anOperation
creator2= ConcreteCreator2()
creator2.anOperation
}
Client
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.