// Class Hamming:
//     Produce all integers with prime factors from a given list

// Code does not include statements supporting trace display

// Include Stream, Times, Merge classes here

import java.awt.*;

class IntObject
{
   int number;
   
   public IntObject (int n) { number = n; }
   public int valueOf () { return number; }
}

class Hamming extends Stream
{
   int primes[], index;
   
   public Hamming (int p[], int i) {  primes = p;  index = i;  }

   public void run ()
   {
      
      putIt(new IntObject(primes[index]));

      Stream s = new Times(primes[index], new Hamming(primes, index));
      if (index != 0) s = new Merge(s, new Hamming(primes, index-1));

      while (true)
      {
         putIt(s.next());
      }
   }
}

public class Hamm extends java.applet.Applet
{
   Stream hamming;
   TextField out;
   Object object;
   ...
   
   public void init ()
   {
      ...
      int a[] = new int[3]; a[0] = 11; a[1] = 5; a[2] = 3;
      hamming = new Hamming(a, 2);
      ...
   }
   ...
   public boolean action (Event evt, Object obj)
   {
      ...
      object = hamming.next();
      int n = ((IntObject)(object)).valueOf();
      out.setText(out.getText()+" "+n);
      ...
      return super.action(evt, obj);
   }
}