( --> )
Object-Oriented Application Architecture
class LineOfSquaresOOAA
{
// main method
static public void main (String args[])
{
LineOfSquares los = new LineOfSquares();
IO.print("The perimeter of the line of squares is ");
IO.println(los.perimeter());
}
}
class LineOfSquares
{
// instance variables
private int nrSquares;
private double squareSide;
// constructor
public LineOfSquares()
{
IO.print("How many squares in the line? ");
nrSquares = IO.read_int();
IO.print("What is the area of the line of squares? ");
double lineArea = IO.read_double();
double squareArea = lineArea / nrSquares;
squareSide = Math.sqrt(squareArea);
}
// other methods
public double perimeter()
{
return squareSide * eeCount();
}
private int eeCount()
{
return ( ( nrSquares * 2 ) + 2 );
}
}