StringArray.java

StringArray.java · 852 B

From the archive palrichclient.zip

Download the archive   « Back to the archive contents

/*
    Java Mud Client -- StringArray module
    by Michael Barton <red@smileyface.com>
    Originally written for Divine Blood, telnet://shell.tetradine.com:4000

    Permission is granted to modify and distribute freely.
    Credit/links are appreciated, but not necessary.
    Bugs and other issues can be noted to red@smileyface.com.
*/

public class StringArray
{
  String[] arr = null;
  int length = 0;
  int max = 25;
  int i = 0;
  int pos = -1;
  public StringArray(int j)  {arr = new String[j];max=j;}
  public StringArray()       {arr = new String[max];}
  public void push(String s) {for(i=max-2;i>0;)arr[i]=arr[--i];arr[0]=s;}
  public String next()       {if (pos<max) return arr[++pos];return "";}
  public String last()       {if (pos>0) return arr[--pos];return "";}
  public void reset()        {pos = -1;}
}

Site Stats

Snippets: 1791
Codebases: 571