author | Christian Urban <christian.urban@kcl.ac.uk> |
Sat, 09 Jul 2022 14:11:07 +0100 | |
changeset 563 | c92a41d9c4da |
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 |