// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.Vector;

public class CombinedRNG implements RNG {
   // parameters
   private Vector generators;
   private Combiner combine;

   // set
   public void setGenerators(Vector gen) {
      generators = gen;
      return;
   }
   public void setCombine(Combiner comb) {
      combine = comb;
      return;
   }

   // interface
   public void init(int seed) {
      for(int i = 0; i < generators.size(); i++) {
         ((RNG)generators.get(i)).init(seed);
      }
   }
   public int getMaxInt() {
      return 2147483647;
   }
   public int getInt() {
      return (int)(getDouble()*getMaxInt());
   }
   public int getInt(int n) {
      return (getInt() % n);
   }
   public double getDouble() {
      return combine.getDouble(generators);
   }
}
