author | Christian Urban <urbanc@in.tum.de> |
Mon, 27 Feb 2017 23:53:48 +0000 | |
changeset 221 | c21938d0b396 |
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 |