Class Box

java.lang.Object
  extended byBox

public class Box
extends Object

A Box has a width, a height and a paintChar used used to paint the Box on a Screen. Examples:

  new Box( 3, 4, 'G' )   new Box( 1, 1, '$' )

          GGG                     $
          GGG
          GGG
          GGG
 

Version:
3

Constructor Summary
Box(int width, int height, char paintChar)
          Construct a box.
 
Method Summary
 int getHeight()
          Get the height of this Box.
 int getWidth()
          Get the width of this Box.
static void main(String[] args)
          Unit test for class Box, assuming Screen and Terminal work.
 void paintOn(Screen s)
          Paint this Box on Screen s at position (0,0).
 void paintOn(Screen s, int x, int y)
          Paint this Box on Screen s at position (x,y).
 void setHeight(int height)
          Set the height of this Box.
 void setWidth(int width)
          Set the width of this Box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Box

public Box(int width,
           int height,
           char paintChar)
Construct a box.

Parameters:
width - width in (character) pixels.
height - height in (character) pixels.
paintChar - character used for painting this Box.
Method Detail

getHeight

public int getHeight()
Get the height of this Box.

Returns:
the height in (character) pixels.

getWidth

public int getWidth()
Get the width of this Box.

Returns:
width of box (expressed as a number of characters).

main

public static void main(String[] args)
Unit test for class Box, assuming Screen and Terminal work.


paintOn

public void paintOn(Screen s)
Paint this Box on Screen s at position (0,0).

Parameters:
s - the Screen on which this box is to be painted.

paintOn

public void paintOn(Screen s,
                    int x,
                    int y)
Paint this Box on Screen s at position (x,y).

Parameters:
s - the screen on which this box is to be painted.
x - the x position for the box.
y - the y position for the box.

setHeight

public void setHeight(int height)
Set the height of this Box.

Parameters:
height - the new height in (character) pixels.

setWidth

public void setWidth(int width)
Set the width of this Box.

Parameters:
width - the new width in (character) pixels.