import java.awt.*;
import javax.swing.*;

public class TilingWindow extends JFrame {

  public int widthRatio(JFrame j) {
    return this.getWidth() / j.getWidth();
  }

  public boolean canTileSideways(int i, JFrame j) {
    return i * j.getWidth() <= this.getWidth();
  }

  public boolean canTile(int i, JFrame j) {
    int numCols= this.getWidth() / j.getWidth();
    int numRows= this.getHeight() / j.getHeight();
    return i <= numCols * numRows;
  }

  /** Same method, no local variables: */
  public boolean canTile2(int i, JFrame j) {
    return i <=
      (this.getWidth() / j.getWidth()) * (this.getHeight() / j.getHeight());
  }

/*

  Type this into the Interactions pane to test TilingWindow:

    import javax.swing.*;
    TilingWindow t= new TilingWindow();
    t.setSize(1000, 2000);
    JFrame j= new JFrame();
    j.setSize(100, 200);
    t.widthRatio(j)
    t.canTileSideways(10, j)
    t.canTileSideways(11, j)
    t.canTile(5, j)
    t.canTile(10, j)
    t.canTile(11, j)

*/
}
