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 15:30
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
Python. primary u.s. interstate highways are numbered 1-99. odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. thus, the 405 services the 5, and the 290 services the 90. given a highway number, indicate whether it is a primary or auxiliary highway. if auxiliary, indicate what primary highway it serves. also indicate if the (primary) highway runs north/south or east/west.
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, 19.02.2020 22:02
question
Mathematics, 19.02.2020 22:02
question
Mathematics, 19.02.2020 22:02
Questions on the website: 13722361