// file: Seed.java // author: Robert Keller // purpose: a Seed is an object which can grow into something else by // calling a method package polya; import java.io.*; import java.lang.*; /** * A Seed can grow into any other Object. **/ class Seed { Object value; /** * Create a Seed. *@arg growable the Growable from which the final value is produced. **/ Seed(Growable growable) { this.value = growable; } /** * grow the seed, iterating as long as the result is a Growable, * returning the final value. **/ Object grow() { while( value instanceof Growable ) { value = ((Growable)value).grow(); } return value; } }