Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:30, westjayson69
Requirement types discussed during software development include functional and color scheme nonfunctional and code style constraint and nonfunctional fashionable and functional.
Answers: 2
image
Computers and Technology, 22.06.2019 11:10, golderhadashaowtatz
Which are not examples of chronic or persistent stress? moving
Answers: 1
image
Computers and Technology, 23.06.2019 00:30, Thisisdifinite
Which of the following would you find on a network
Answers: 3
image
Computers and Technology, 23.06.2019 02:30, chaaaa
People with high self-esteem: accept their strengths and weaknesses. believe that failed experiences are failures of their whole self. feel good about who they are only when they reach total success. need positive external experiences to counteract negative feelings that constantly plague them.
Answers: 1
Do you know the correct answer?
Implement a class, Box, similar to the class in a previous review exercise. But the new implementati...

Questions in other subjects:

Konu
World Languages, 04.07.2019 22:00
Konu
History, 04.07.2019 22:00