Question: Java Programming Define a class in Java named RectTile to represent a rectangular tile with length, width, and Color as attributes or states. The operations
Java Programming
Define a class in Java named RectTile to represent a rectangular tile with length, width, and Color as attributes or states. The operations of RectTile should include setLength for setting the length, setWidth for setting the width, setColor for setting the color, and getArea for getting the area of the rectangular tile (computed as length width). There must also be corresponding methods to get length, width, and color. NB: The definitions of setLength and setWidth must be such that an error message is displayed if length or width is a negative value. Do not add a constructor.
a) Create an ArrayList or a regular array called tiles and assign one instance of RectTile to it.
b) Suppose 50 objects of type RectTile have been assigned to the array tiles. How would you use a for...loop to print the area of each instance of RectTile assigned to the array?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
