FileDocCategorySizeDatePackage
SideEffects.javaAPI DocExample1585Thu May 13 18:31:10 BST 2004None

Enemy

public class Enemy extends Object
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.

Fields Summary
Constructors Summary
Methods Summary
public voidmunge(SideEffects md)

		System.out.println("Object is " + md);
		md.year = 0;
		md.td.setYear(71);	  // Ignore deprecation warnings