$29.99
Overview
This lab’s purpose is to provide students with experience in inheritance of classes and working with multiple classes. It is recommended that students use command line tools and editors for this lab (though it is not strictly speaking required). This lab will require students to build on their previous lab experience, in which a version of the cowsay utility was created.
Specification
cowsay.py (Program Driver)
Your program must accept command line arguments as follows:
python3 cowsay.py -l Lists the available cows
python3 cowsay.py MESSAGE Prints out the MESSAGE using the default COW python3 cowsay.py -n COW MESSAGE Prints out the MESSAGE using the specified COW
In addition, this version of the utility handles a special set of Cow-derived Dragon class (and its subclasses). Whenever a dragon-type cow is selected, the display of the message must be followed by a line stating whether or not the dragon is fire-breathing:
>python3 cowsay.py -n dragon Fiery RAWR
Fiery RAWR
|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_'/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _ ( // /) '/,_ _ _/ ( ; -. | _ _.-~ .-~~~^-.
(( / / )) ,-{ _ `.|.-~-. .~ `.
(( // / )) '/ / ~-. _.-~ .-~^-.
(( /// )) `. { } /
(( / )) .----~-. -' .~ `. __
///.----..> _ -~ `. ^-` ///-._ _ _ _ _ _ _}^ - - - - ~ `-----'
This dragon can breathe fire. >python3 cowsay.py -n ice-dragon Ice-cold RAWR
Ice-cold RAWR
|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_'/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _ ( // /) '/,_ _ _/ ( ; -. | _ _.-~ (( / / )) ,-{ _ `.|.-~-. (( // / )) '/ / ~-. _.-~ (( /// )) `. { } (( / )) .----~-. -' ///.----..> _ ///-._ _ _ _ _ _ _}^ - - - - ~
This dragon cannot breathe fire.
Cow Class
__init__(self, name)
// Constructor
get_name(self)
// Returns name of this cow object
get_image(self)
// Return image for this cow object
set_image(self, image) // Sets the image for this cow object to image
Dragon Class
The Dragon class must be derived from the Cow class and must make all of its methods available. In addition, Dragon must provide the following methods:
__init__(self, name, image)
Constructor; creates a new Dragon object with the given name and image.
can_breathe_fire()
This method should exist in every Dragon class. For the default Dragon type, it should always return True.
IceDragon Class
The IceDragon class must be derived from the Dragon class and must make all of its methods available:
__init__(self, name, image)
Constructor; creates a new IceDragon object with the given name and image.
can_breathe_fire()
For the IceDragon type, this method should always return False.
Submissions
NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for your submission!
Files: cowsay.py, cow.py, dragon.py, ice_dragon.py, heifer_generator.py
Method: Submit on ZyLabs
Sample Output
>python3 cowsay.py Hello World!
Hello World!
^__^
(oo)_______
(__) )/
||----w |
|| ||
>python3 cowsay.py -n kitteh Moew-Moew!
Moew-Moew!
("`-' '-/") .___..--' ' "`-._
` *_ * ) `-. ( ) .`-.__. `)
(_Y_.) ' ._ ) `._` ; `` -. .-'
_.. `--'_..-_/ /--' _ .' ,4
( i l ),-'' ( l i),' ( ( ! .-'
>python3 cowsay.py -l
Cows available: heifer kitteh dragon ice-dragon
>python3 cowsay.py -n ninja Hello world!
Could not find ninja cow!
>python3 cowsay.py -n dragon Firey RAWR
Fiery RAWR
|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_'/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _ ( // /) '/,_ _ _/ ( ; -. | _ _.-~ .-~~~^-.
(( / / )) ,-{ _ `.|.-~-. .~ `.
(( // / )) '/ / ~-. _.-~ .-~^-.
(( /// )) `. { } /
(( / )) .----~-. -' .~ `. __
///.----..> _ -~ `. ^-`
///-._ _ _ _ _ _ _}^ - - - - ~ `-----'
This dragon can breathe fire.
>python3 cowsay.py -n ice-dragon Ice-cold RAWR
Ice-cold RAWR
|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_'/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _ ( // /) '/,_ _ _/ ( ; -. | _ _.-~ .-~~~^-.
(( / / )) ,-{ _ `.|.-~-. .~ `.
(( // / )) '/ / ~-. _.-~ .-~^-.
(( /// )) `. { } /
(( / )) .----~-. -' .~ `. __
///.----..> _ -~ `. ^-`
///-._ _ _ _ _ _ _}^ - - - - ~ `-----'
This dragon cannot breathe fire.