subject

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.)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:20
What’s resistance in an electrical circuit ?
Answers: 1
question
Computers and Technology, 23.06.2019 15:10
What role did women fill during world war ii?
Answers: 1
question
Computers and Technology, 24.06.2019 00:20
The guy wire bd exerts on the telephone pole ac a force p directed along bd. knowing the p must have a 720-n component perpendicular to the pole ac, determine the magnitude of force p and its component along line ac.
Answers: 2
question
Computers and Technology, 24.06.2019 12:30
Nikki sent flyers in the mail to all houses within the city limits promoting her computer repair service what type of promotion is this and example of
Answers: 1
You know the right answer?
Implement a class, Box, similar to the class in a previous review exercise. But the new implementati...
Questions
question
Mathematics, 04.12.2019 06:31
question
Chemistry, 04.12.2019 06:31
Questions on the website: 13722363