class IAbstract {
module operation {
error "Abstract"
}
}
Class Abstraction1 as iAbstract {
Private:
impl=pointer()
Public:
module operation {
.impl=>operationImp
}
Class:
module Abstraction1 (p as *IImplementor) {
.impl<=p
}
}
Class Abstraction2 as iAbstract {
Private:
impl=pointer()
Public:
module operation {
.impl=>operationImp
}
module operation1 {
Print "extend Abstraction"
}
Class:
module Abstraction2 (p as *IImplementor) {
.impl<=p
}
}
Class IImplementor {
module operationImp {
error "Abstact"
}
}
Class Implementor1 as IImplementor {
module operationImp {
Print "result from Implementor1"
}
}
Class Implementor2 as IImplementor {
module operationImp {
Print "result from Implementor2"
}
}
M=Abstraction1(Pointer(Implementor1()))
M.operation
M=Abstraction1(Pointer(Implementor2()))
M.operation
M=Abstraction2(Pointer(Implementor1()))
M.operation
M.operation1
\\ extends both Abstraction and Implementor
Class Abstraction3 as Abstraction2 {
Private:
impl=pointer()
Public:
module operation {
.impl=>operationImp
}
module operation1 {
.impl=>operationImp2
}
Class:
module Abstraction3 (p as *Implementor3) {
.impl<=p
}
}
Class Implementor3 as Implementor2 {
module operationImp2 {
Print "result 2 from Implementor3"
}
}
M=Abstraction3(Pointer(Implementor3()))
M.operation
M.operation1
Print M is type IAbstract
Print M is type Abstraction3
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.