author | Chengsong |
Sat, 05 Feb 2022 15:30:45 +0000 | |
changeset 413 | b85f8e28fbd8 |
parent 44 | a751aa1ee4f7 |
permissions | -rw-r--r-- |
44 | 1 |
package Main |
2 |
||
3 |
object CompoundClasses { |
|
4 |
trait Cloneable extends java.lang.Cloneable { |
|
5 |
override def clone(): Cloneable = { super.clone(); this } |
|
6 |
} |
|
7 |
||
8 |
trait Resetable { |
|
9 |
def reset: Unit |
|
10 |
} |
|
11 |
||
12 |
def cloneAndReset(obj: Cloneable with Resetable): Cloneable = { |
|
13 |
val cloned = obj.clone() |
|
14 |
obj.reset |
|
15 |
cloned |
|
16 |
} |
|
17 |
} |
|
18 |