Explore BrainMass

Explore BrainMass

    Rectangle class using Java

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Create a Rectangle class with
    - Private attributes for width and height
    - A default constructor that sets the height to 10 and width to 25.
    - An overloaded constructor that takes integer width and height arguments, uses a separate method to check whether the width and height fall within the range between 0 and 30, and throws an exception if out of range.
    - getArea and draw methods for the class.
    - getArea will calculate the area of the rectangle based on the width and height.
    - draw will outline the rectangle using asterisks. The number of asterisks used will match the width and height of the rectangle.

    Create a TestRectangle class that tests both constructors of the Rectangle class.

    © BrainMass Inc. brainmass.com October 10, 2019, 4:53 am ad1c9bdddf

    Solution Summary

    This solution helps crate a Rectangle class with private attributes for width and height, a default constructor, an overloaded constructor that takes integer width and height, getAre to draw methods for the class and calculate the are of the rectangle. It can also outline the rectangle using asterisks.