Let’s build a virtual factory that produces patterned fabric of various colors. To do that, write a secondary constructor of the given class Fabric. The secondary constructor should take color, pattern, and patternColor as arguments and set the corresponding property values. Then, print the updated information about the fabric.
The complete process of creating an object of the Fabric class should be as follows:
- Plain fabric is produced, and the message
<color> fabric is createdis output, with the corresponding argument value for<color>. - Some color pattern is applied to the fabric. The message
<patternColor> <pattern> pattern is printed on the fabricis shown, with the appropriate values for<pattern>and<patternColor>.
For example, creating a new object val fabric = Fabric("white", "dots", "black") is accompanied by the following output:
white fabric is created
black dots pattern is printed on the fabric
Hint: don't forget to set property values in the secondary constructor.