The computer program cowsay generates ASCII pictures of a cow with a message.

+----------------------------+
| Moo may represent an idea, |
|  but only the cow knows.   |
+----------------------------+
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

It can also generate pictures using pre-made images of other animals such as Tux the Penguin1, the Linux mascot.

+----------------------------+
| Moo may represent an idea, |
|  but only the cow knows.   |
+----------------------------+
   \
    \
        .--.
       |^_^ |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

The computer program uses pre-made images that are stored in text files with the extension .cow, enabling it to produce different variants of "cows". Each such text file also contains two occurrences of a pair of braces ({}) enabling the program to produce different kinds of eyes. The program initially was a kind of inside joke within hacker culture, but has been around long enough that its use has become rather widespread.

Assignment

Define a class Cowsay that can be used to generate ASCII pictures of a "cow" with a message. The objects of this class must at least support the following methods:

Example

In the following interactive session we assume that the text files cow.cow4 and tux.cow5 are in the current directory. Note that a docstring is nothing but an ordinary string, which requires that each backslash that occurs literally in the docstring must be repeated twice. Click here to convert the following interactive session into a docstring.

>>> quote = Cowsay(['Moo may represent an idea,', 'but only the cow knows.'])
>>> quote
+----------------------------+
| Moo may represent an idea, |
|  but only the cow knows.   |
+----------------------------+
>>> print(quote)
+----------------------------+
| Moo may represent an idea, |
|  but only the cow knows.   |
+----------------------------+
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
>>> quote.setEyes(33)
Traceback (most recent call last):
AssertionError: invalid eyes
>>> quote.setEyes('***')
Traceback (most recent call last):
AssertionError: invalid eyes
>>> quote.setEyes('^^')
>>> print(quote)
+----------------------------+
| Moo may represent an idea, |
|  but only the cow knows.   |
+----------------------------+
        \   ^__^
         \  (^^)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
>>> quote.setImage('tux.cow')
>>> print(quote)
+----------------------------+
| Moo may represent an idea, |
|  but only the cow knows.   |
+----------------------------+
   \
    \
        .--.
       |^_^ |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/
Traceback (most recent call last):
AssertionError: invalid eyes