public class Boxes
{
public static void main (String []
args)
{
Box box =
new Box (5, 4);
box.displayBoxTop
();
box.displayBoxMiddle
();
box.displayBoxBottom
();
} // main method
} // class Boxes
class Box
{
private int width, height;
Box (int w, int h)
{
width = w;
height = h;
} // constructor
public void displayBoxTop ()
{
for (int col
= 0; col < width; col++)
System.out.print ("* ");
System.out.println
("");
} // method displayBoxTop
public void displayBoxMiddle ()
{
for (int row
= 0; row < height-2; row ++)
{
System.out.print ("* ");
for (int col = 0; col < width-2; col++)
System.out.print (" ");
System.out.println ("*");
}
} // method displayBoxMiddle
public void displayBoxBottom ()
{
for (int col
= 0; col < width; col++)
System.out.print ("* ");
System.out.println
("");
} // method displayBoxBottom
} // class Box