FileDocCategorySizeDatePackage
Snake.javaAPI DocExample3299Mon Apr 06 18:10:22 BST 1998None

Snake

public class Snake extends Object implements Cloneable

Fields Summary
private Snake
next
private char
c
Constructors Summary
Snake(int i, char x)

    c = x;
    if(--i > 0)
      next = new Snake(i, (char)(x + 1));
  
Methods Summary
public java.lang.Objectclone()

    Object o = null;
    try {
      o = super.clone();
    } catch (CloneNotSupportedException e) {}
    return o;
  
voidincrement()

    c++;
    if(next != null)
      next.increment();
  
public static voidmain(java.lang.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);
  
public java.lang.StringtoString()

    String s = ":" + c;
    if(next != null)
      s += next.toString();
    return s;