Laboratory 6
Exercise 1
We intend to create a simple tool in Java to create images constituted by characters, called ASCII Art.
The class Shape is abstract and it is extended by a Rectangle, a Circle, a Triangle or an Aggregate. An Aggregate is a complex form that combines two or more shapes. This form allows to create complex shapes in a modular way, for instance, it allows to create a house aggregate which is then used in a city aggregate. The method intersection receives an integer y and returns an array of integers which represents the x points such that (x,y) belongs to the respective shape.
The class Image has the methods to obtain the ASCII art from combined shapes:
- The method line receives the number y of the line and returns a String which corresponds to the y-th line of the image of characters.
- The method toString returns the string with the full image of characters.
(a) Implement it in Java.
(b) Test your program (in a main method).