Class Adaptee {
module methodB (x) {
Print "x=";x
}
function funcB (x, y) {
=x**y
}
}
Class ISomething {
module methodA {
error "abstract"
}
Function funcA {
error "abstract"
}
}
Class Adapter as ISomething {
Private:
inner=pointer()
Public:
module methodA {
.inner=>methodB
}
function funcA {
=.inner=>funcB(![])
}
Class:
module Adapter (p as pointer){
.inner<=p
}
}
Class Client {
module doit (M as ISomething) {
M.MethodA 100
Print M.funcA(2, 3)=8
}
}
C=Client()
Ad=Adapter(Pointer(Adaptee()))
C.doit Ad
Class Adaptee {
module methodB (x, &z) {
Print "x=";x
z++
}
function funcB (x, y) {
=x**y
}
}
Class Adaptee1 {
module methodklm (x, &z) {
Print "x*2=";x*2
z+=5
}
function funcMN (x, y) {
=x+y
}
}
Class ISomething {
module methodA {
error "abstract"
}
Function funcA {
error "abstract"
}
}
Class Adapter as ISomething {
Private:
inner=pointer()
Public:
module methodA {
.inner=>methodB
}
function funcA {
=.inner=>funcB(![])
}
Class:
module Adapter (p as *Adaptee){
.inner<=p
}
}
Class Adapter1 as ISomething {
Private:
inner=pointer()
Public:
module methodA {
.inner=>methodklm
}
function funcA {
=.inner=>funcMN(![])
}
Class:
module Adapter1 (p as *Adaptee1){
.inner<=p
}
}
Class Client {
module doit (M as ISomething) {
L=500
M.MethodA 100, &L
Print "L=";L
Print M.funcA(2, 3)=8
}
}
C=Client()
Ad=Adapter(Pointer(Adaptee()))
C.doit Ad
Ad=Adapter1(Pointer(Adaptee1()))
C.doit Ad
module doit (&M as ISomething) {
L=500
M.MethodA 100, &L
Print "L=";L
Print M.funcA(2, 3)=8
}
}
C=Client()
Ad=Adapter(Pointer(Adaptee()))
C.doit &Ad
Ad=Adapter1(Pointer(Adaptee1()))
C.doit &Ad
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.