KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > uk > co > jezuk > mango > generators > IntegerSequence


1 package uk.co.jezuk.mango.generators;
2
3 /**
4  * Returns seed, seed+1, seed+2 ... on successive calls to fn()
5  * Sequence begins at 0 if no seed value is given.
6  * @author Jez Higgins, jez@jezuk.co.uk
7  * @version $Id: IntegerSequence.java 65 2002-07-31 21:59:26Z jez $
8  */

9 public class IntegerSequence implements uk.co.jezuk.mango.Generator
10 {
11   public IntegerSequence()
12   {
13     seed_ = 0;
14   } // IntegerSequence
15

16   public IntegerSequence(int seed)
17   {
18     seed_ = seed;
19   } // IntegerSequence
20

21   public IntegerSequence(Integer JavaDoc seed)
22   {
23     seed_ = seed.intValue();
24   } // IntegerSequence
25

26   public Object JavaDoc fn()
27   {
28     return new Integer JavaDoc(seed_++);
29   } // fn
30

31   private int seed_;
32 } // Generator
33

34
Popular Tags