Question: ex2 Define the class Rectangle that contains double instance variables named width and height, and a static variable named printChar. Include the following: A no-arg

ex2  ex2 Define the class Rectangle that contains double instance variables named

Define the class Rectangle that contains double instance variables named width and height, and a static variable named printChar. Include the following: A no-arg constructor that creates a default rectangle with 1.0 for both width and height. A constructor that creates a rectangle with the specified width, and height. Get and set methods for all the instance variables. A method getArea() that returns the area of the rectangle. A static method setPrintChar() that modifies the static variable A toString() method that returns a String that represents an outline drawing of the rectangle using the character given by printChar, For example, if printChar were 'c' and one Rectangle had a width of 5 and a height of 4, then printing the toString() method to output would give ccccc c c ccccc Write a test program that first sets the printChar for the Rectangle class as '*', then creates two Rectangle Objects of reasonable sizes. Print out each rectangle separately to output using the toString() method, followed by the value of that rectangle's area. Change the printChar to a reasonable (non-white-space) character of your choosing, modify both instance variables for both Rectangle Objects, and then repeat the output process: print out each rectangle separately to output followed by the value of that rectangle's area

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!