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, 23.06.2019 12:00
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
question
Computers and Technology, 23.06.2019 21:50
Description: write function lastfirst() that takes one argument—a list of strings of the format "lastname, firstname" —and returns a list consisting of two lists: (a) a list of all the last names (b) a list of all the first names
Answers: 2
question
Computers and Technology, 24.06.2019 01:30
Could you find out how im still getting an 83 percent on this in edhesive a = input("enter an animal: ") s = input ("enter a sound: ") e = "e-i-e-i-o" print ("old macdonald had a farm, " + e) print ("and on his farm he had a " + a + "," + e) print ("with a " + s + "-" + s + " here and a " + s + "-" + s + " there") print ("here a " + s+ " there a " + s) print ("everywhere a " + s + "-" + s ) print ("old macdonald had a farm, " + e)
Answers: 2
question
Computers and Technology, 24.06.2019 17:30
When you type january in a cell, then copy it using the fill handle to the cells below and the data automatically changes to february, march, april, and so on, what is this feature called? auto fill automaticcopy monthfill textfill
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, 20.02.2021 02:40
question
Mathematics, 20.02.2021 02:40
question
Mathematics, 20.02.2021 02:40
question
Mathematics, 20.02.2021 02:40
question
Mathematics, 20.02.2021 02:40
Questions on the website: 13722362