Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
63
Task/Abstract-type/M2000-Interpreter/abstract-type.m2000
Normal file
63
Task/Abstract-type/M2000-Interpreter/abstract-type.m2000
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
Class BaseState {
|
||||
Private:
|
||||
x as double=1212, z1 as currency=1000, k$="ok"
|
||||
Module Err {
|
||||
Module "Class.BaseState"
|
||||
Error "not implement yet"
|
||||
}
|
||||
}
|
||||
Class AbstractOne {
|
||||
Public:
|
||||
Group z {
|
||||
Value {
|
||||
Link parent z1 to z1
|
||||
=z1
|
||||
}
|
||||
}
|
||||
Function M(k as double) {
|
||||
.Err
|
||||
}
|
||||
Module AddCurrency (k as currency) {
|
||||
.Err
|
||||
}
|
||||
Function GetString$ {
|
||||
.Err
|
||||
}
|
||||
Class:
|
||||
Module AbstractOne {
|
||||
If Not Match("G") Then Exit
|
||||
Read x
|
||||
\\ combine x with This
|
||||
This=x
|
||||
}
|
||||
}
|
||||
\\ create new group as K
|
||||
K=AbstractOne(BaseState())
|
||||
Try ok {
|
||||
Print K.GetString$()
|
||||
}
|
||||
If Not ok Then Print Error$
|
||||
\\ Now Add final functions/modules
|
||||
Group k {
|
||||
Function Final M(k as double) {
|
||||
=.x*k
|
||||
}
|
||||
Module Final AddCurrency (k as currency) {
|
||||
.z1+=k
|
||||
}
|
||||
Function Final GetString$ {
|
||||
=.K$
|
||||
}
|
||||
}
|
||||
Print k.M(100), k.GetString$()
|
||||
K.AddCurrency 50.12
|
||||
Def ExpType$(x)=Type$(x)
|
||||
Print k.z=1050.12, ExpType$(k.z), Type$(k.z) ' true, Currency, Group
|
||||
\\ Now combine AbstractOne without new BaseState
|
||||
\\ but because all functions are final in k, nothing combined
|
||||
k=AbstractOne()
|
||||
Print k.M(100), k.GetString$()
|
||||
For k {
|
||||
\\ we can use For Object {} and a dot before members to get access
|
||||
Print .z=1050.12, ExpType$(.z), Type$(.z) ' true, Currency, Group
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue