Question: Code the Rectangle class including the following: . 6 instance variables for the rectangle's x, y centre point, its width and height, its colour and

 Code the Rectangle class including the following: . 6 instance variables

Code the Rectangle class including the following: . 6 instance variables for the rectangle's x, y centre point, its width and height, its colour and its border width. All are of type double except the rectangle's colour which is of type Color (you will need to import java.awt.*). . a no parameter constructor that initialises all instance variables to sensible default values and a 6 parameter constructor which supplies initial values for all 6 instance variables. . The canvas for the graphics application is 1.0 X 1.0 unit square with the origin in the bottom left hand corner. The default radius of the drawing pen and therefore the Rectangle's default border width is 0.002. This should help you choose sensible default values and write guardian code to protect a Rectangle's data. . The graphics application includes calls to the 6 parameter constructor which look like: . Rectangle(x, y, width, height, c, penRadius). accessors and mutators for all instance variables . You will need two mutators for a rectangle's colour. One should accept a single parameter of type Color. The other should accept 4 int parameters in a valid range for r, g, b, alpha. . Only one accessor is required for a rectangle's colour. It should return an object of type Color methods to calculate a rectangle's perimeter and area . a toString() method You can use the Rectangle class developed in this learning module as a start if you like. Code your Rectangle class bit-by-bit and test with a driver class at each step. Do not code the entire class and hope it all works. If this Rectangle class was to be used in an application with other classes it is essential to thoroughly test it in isolation (so called unit test) using a dedicated testing, driver class before inserting into the application. Then and only then should its interaction with other classes be tested (so called integration testing). Finally the entire application can be tested (so called system test)

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 Programming Questions!