Question: Rectangle.java ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In this Minilab, you are given a class called Rectangle, which describes a 2-dimensional Rectangle. You should. 1- Look at the Rectangle code


Rectangle.java
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


In this Minilab, you are given a class called Rectangle, which describes a 2-dimensional Rectangle. You should. 1- Look at the Rectangle code and be familiar with it. It has: Data: that stores width and height (as ints). Constructors: - default constructor which receives nothing and always sets the width and height to 5 and 2. parameterized constructor which receives 2 ints (width, then height) and sets the width and height to what is received Methods: toString() - returns its representation as a String. Dimensions are included as width, then height. getWidth() - returns the width getPerimeter() - returns its perimeter getSumOfDimensions returns the width + height 2- You are to create another class called Box, which will be defined as a subclass of Rectangle. It should have the following: Data: It should inherit 2 dimensions (so you will have to change how Rectangle's data is declared) and then declare a 3rd dimension which will be the depth. All dimensions will be ints. Constructors: There should be 2 constructors It should have a default constructor that sets its 3 dimensions (width, height, and depth) to 5, 2, and 6. (Note that Rectangle has a default constructor that also sets the first 2 dimensions to 5 and 2 so you can call super() to set the first 2 dimensions if you want). It should also have a parameterized constructor that receives 3 ints (width, then height, then depth) and sets the data to whatever is received. The parameterized constructor should check to see if any of the dimensions are negative - if so, it should throw new IllegalArgumentException"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
