public static void main(String[] args) { Snake s = new Snake(5, 'a'); System.out.println("s = " + s); Snake s2 = (Snake) s.clone(); System.out.println("s2 = " + s2); s.increment(); System.out.println("after s.increment, s2 = " + s2); monitor.expect( new String[] {"s = :a:b:c:d:e", "s2 = :a:b:c:d:e", "after s.increment, s2 = :a:c:d:e:f"}); }
public String toString() { String s = ":" + c; if (next != null) s += next.toString(); return s; }
public void increment() { c++; if (next != null) next.increment(); }