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, 21.06.2019 15:40
Establish which of the following statements are true. (a) a sequence is convergent if and only if all of its subsequences are convergent. (b) a sequence is bounded if and only if all of its subsequences are bounded. (c) a sequence is monotonic if and only if all of its subsequences are monotonic.
Answers: 2
question
Computers and Technology, 21.06.2019 16:30
Sara is writing a program to input her monthly phone bills and output the month name and amount for the month with maximum amount. she has defined an array to hold the month names. complete the pseudocode program. [6] # program to output maximum month's phone bill monthname ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"] # define an array to hold the phone bills for each month
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
How would you cite different books by the same author on the works cited page? moore, jack h. folk songs and ballads. salem: poetry press, 1999. print. moore, jack h. ballads in poetry – a critical review. dallas: garden books, 1962. print. moore, jack h. folk songs and ballads. salem: poetry press, 1999. print. –––. ballads in poetry – a critical review. dallas: garden books, 1962. print. moore, jack h. ballads in poetry – a critical review. dallas: garden books, 1962. print. moore, jack h. folk songs and ballads. salem: poetry press, 1999. print. moore, jack h. ballads in poetry – a critical review. dallas: garden books, 1962. print. –––. folk songs and ballads. salem: poetry press, 1999. print.
Answers: 2
question
Computers and Technology, 24.06.2019 08:20
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
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, 25.03.2021 08:10
question
English, 25.03.2021 08:10
question
Mathematics, 25.03.2021 08:10
question
Health, 25.03.2021 08:10
question
Mathematics, 25.03.2021 08:10
question
Mathematics, 25.03.2021 08:10
Questions on the website: 13722360