Exercise: Console Color Factory
Learn how to produce colored output using the color corresponding to the class name.
We'll cover the following...
Problem statement
Create a class called ColorConsole
that has just one empty method called log()
. Then, create three subclasses: RedConsole
, BlueConsole
, and GreenConsole
. The log()
method of every ColorConsole
subclass will accept a string as input and will print that string to the console using the color that gives the name to the class. Then, create a factory function that takes color as input, such as 'red'
, and returns the related ...