Question: in java code Create a new class named BoxDriver in the com.iq.exercises package. Ensure that this class has a main() method defined. In the main

Create a new class named BoxDriver in the com.iq.exercises package. Ensure that this class has a main() method defined. In the main method of BoxDriver, create two Box objects using the keyword new. a. A box named box1 with a length of 5, a width of 6 and a height of 7 b. A box named box2 where all three sides are 10 Using the get methods, print out the value for each attribute of both boxes. Ensure that the attributes were set correctly by the Box constructors. Execute the main method for BoxDriver. The output should be like the following. If there are any errors in your Box code at this point, correct them and re-run the test. Box 1 length is + 5.0 Box 1 width is + 6.0 Box 1 height is + 7.0 Box 2 length is + 10.0 Box 2 width is + 10.0 Box 2 height is + 10.0 Ensure that your set methods work correctly. Call each set method for box1 changing the values to the following and then use the get methods to ensure that the attributes were set correctly. a. Length = 3 b. Width = 4 c. Height = 5 Call the getVolume () and get SurfaceArea () methods on boxi and ensure they are functioning correctly. If not, fix the code and re-test. Execute the printBox() for box1. Ensure that it is functioning correctly. If not, fix the code and re-test. Using the setLength() method, change the length of box1 to -5. Execute the printBox() method again. What happens? You should receive a message stating that the box contains invalid attributes. In order to avoid setting attributes to invalid values, re-code the set methods of the Box class to only accept values greater than 0. If a value less than or equal to zero is detected, print an error message like the following: System.out.println("Length must be greater than 0"); Re-run your BoxDriver main method. You should now receive an error message when you try and set the length to -5. Test the other two set methods in the same manner
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
