Implement a class, Box, similar to the class in a previous review exercise. But the new implementation of Box will have better encapsulation. Here is the documentation for Box:

class Box

A class that implements a cardboard box.

Constructors

Box ( double width, double height, double length )

Box ( double side )

Methods

double volume()

double area()

Look at the previous programming exercise for more discussion and for code which easily can be modified for this and the next two exercises.

In the current implementation of Box make all the instance variables private. This means that only methods of a Box object can see that object's data. The object will be immutable if there are no access methods that make changes to this data. An immutable object is one whose data does not change. You may remember that String objects are immutable---once the characters of the String are set with a constructor they never change (although they can be used to create other String objects.) There are many advantages to using immutable objects, especially when programming with threads (which is how nearly all big programs are written.)

Give public access to the methods of Box.

Test your Box class with several versions of this program:

class BoxTester
{

public static void main ( String[] args )
{
Box box = new Box( 2.5, 5.0, 6.0 ) ;

System.out.println( "Area: " + box.area() + " volume: " + box. volume() );

System.out.println( "length: " + box.length + " height: " + box. height +
"width: " + box.width ) ;

}
}
(The above program will not compile, which is what you want. Reflect on why it does not compile and fix it so that it does.)