Simple demo of avoiding side-effects by using Object.clone()
to duplicate an object before passing it to your enemy's methods.
Cloneable is a "marker" interface: it has no methods, but is tested
for by Object.clone. If you implement it, you tell Object.clone that
your data is stable enough that field-by-field copy is OK. |