public class Gcd {
  private int myX, myY; // want gcd of these two ints
  
  public Gcd(int x, int y) {
    myX = x;
    myY = y;
  }
  
  public int calculateGcd( ) {
    // initialize local vars x and y
    int x = myX;
    int y = myY;
    // System.err.println("x is " + x + " and  y is "
    //                     + y);
    // loop while y > 0
    while ( y > 0 ) {
      int r = x % y;
      x = y;
      y = r;
      // System.err.println("x is " + x + " and  y is "
      //                   + y + " and r is " + r);
    }
    return x;
  }
  
  public void reset(int x, int y) {
    myX = x;
    myY = y;
  }
  
  public String toString( ) {
    return "The GCD of " + myX + " and " +
      myY + " is " + calculateGcd();
  }
  
}