Purchase Solution

Rectangle class using Java

Not what you're looking for?

Ask Custom Question

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.

Purchase this Solution

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.

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Javscript Basics

Quiz on basics of javascript programming language.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.