Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q4) THE BOX CLASS Write a utility class Box and a driver class, BoxTest.java, used to test each constructor and method in the class. A
Q4) THE BOX CLASS Write a utility class Box and a driver class, BoxTest.java, used to test each constructor and method in the class. A Box object should have three instance variables : double height, width, depth; Include three constructors: public Box(double w, double h, double d) initializes the three instance variables public Box() initializes all instance variables to 1 o public Box(double side) initializes all instance variables to side SESSION 2 PAGE13 Include the methods o public double volume() returns the volume of this Box o public int surfaceArea) returns the surface area of this Box o public String toString) retuns a String representation of this Box such as "Box with dimensions 4.3 x 6.5 x 9.0" o public double diagonalLength() returns the length of the diagonal, the square root of the sum of the squares of each dimension, of this Box o Three accessor methods (get methods), one for each instance variable o Three mutator methods (set methods), one for each instance variable
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started