tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
38
Task/Polymorphic-copy/NetRexx/polymorphic-copy.netrexx
Normal file
38
Task/Polymorphic-copy/NetRexx/polymorphic-copy.netrexx
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols binary
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
class RCPolymorphicCopy public
|
||||
|
||||
method copier(x = T) public static returns T
|
||||
return x.copy
|
||||
|
||||
method main(args = String[]) public constant
|
||||
obj1 = T()
|
||||
obj2 = S()
|
||||
System.out.println(copier(obj1).name) -- prints "T"
|
||||
System.out.println(copier(obj2).name) -- prints "S"
|
||||
return
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
class RCPolymorphicCopy.T public implements Cloneable
|
||||
|
||||
method name returns String
|
||||
return T.class.getSimpleName
|
||||
|
||||
method copy public returns T
|
||||
dup = T
|
||||
|
||||
do
|
||||
dup = T super.clone
|
||||
catch ex = CloneNotSupportedException
|
||||
ex.printStackTrace
|
||||
end
|
||||
|
||||
return dup
|
||||
|
||||
-- -----------------------------------------------------------------------------
|
||||
class RCPolymorphicCopy.S public extends RCPolymorphicCopy.T
|
||||
|
||||
method name returns String
|
||||
return S.class.getSimpleName
|
||||
Loading…
Add table
Add a link
Reference in a new issue