, , ,

[SOLVED] Cop3504c lab 07: the cow strikes back

$25

File Name: Cop3504c_lab_07__the_cow_strikes_back.zip
File Size: 348.54 KB

5/5 - (1 vote)

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; however, this lab will be written in C++. Note that you will need to set the language
version to C++17 in your CMakeLists.txt file for this project.
Specification
Students will convert the driver program (cowsay) from Java and also create two new classes – Dragon and
IceDragon. The Dragon class should extend the Cow class, and IceDragon must be derived from Dragon. As
before, the HeiferGenerator class is provided for you – but updated to a C++ version (HeiferGenerator.cpp
and HeiferGenerator.h). It will also handle the new Dragon class and its subtypes. You must also prepare a
CMake build file for this project. Students may implement private attributes and methods if they chose to do so.
This is not required – it is purely optional. No public attributes / methods should be added to the specification!
Executable Specification
Your program must accept command line arguments as follows:
cowsay ‐l Lists the available cows
cowsay MESSAGE Prints out the MESSAGE using the default cow
cowsay ‐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 classes (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:
finn@BMO:~$ ./cowsay ‐n dragon Fiery RAWR
Fiery RAWR

|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_’/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _
( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ .‐~~~^‐.
(( / / )) ,‐{ _ `.|.‐~‐. .~ `.
(( // / )) ‘/ / ~‐. _.‐~ .‐~^‐.
(( /// )) `. { } /
(( / )) .‐‐‐‐~‐. ‐’ .~ `. __
///.‐‐‐‐..> _ ‐~ `. ^‐`
///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ `‐‐‐‐‐’
This dragon can breathe fire.
finn@BMO:~$ cowsay ‐n ice‐dragon Ice‐cold RAWR
Ice‐cold RAWR

|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_’/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _
( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~
(( / / )) ,‐{ _ `.|.‐~‐.
(( // / )) ‘/ / ~‐. _.‐~
(( /// )) `. { }
(( / )) .‐‐‐‐~‐. ‐’
///.‐‐‐‐..> _
///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~
This dragon cannot breathe fire.
Cow Class
The Cow class must have all the same methods as previously required, though students may add private methods.
The methods are repeated here, briefly, for reference. (Note that setImage() should be marked as virtual.)
public Cow(const string& _name) // Constructor
public string& getName() // Returns name of this cow object
public string& getImage() // Return image for this cow object
public virtual void setImage(const string& _image) // Sets image for this cow object
Dragon Class
The Dragon class must be derived from the Cow class and must make all its methods available. You may mark
any additional methods virtual as necessary. In addition, Dragon must provide the following methods:
public Dragon(const string& _name, const string& _image)
Constructor; creates new Dragon object with given name and image. This must be its only public constructor!
public bool canBreatheFire()
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 its methods available:
public IceDragon(const string& _name, const string& _image)
Constructor; creates a new IceDragon object with the given name and image. This should be the only public
constructor for the IceDragon class!
public bool canBreatheFire()
For the IceDragon type, this method should always return false.
HeiferGenerator Class (Provided)
public static vector<Cow*>& getCows()
Returns a reference to a vector of cow object pointers from built-in data set. This will call the Cow constructor
and setImage() methods of the cow class if needed to initialize new cow objects uniquely for each data set.
public static Dragon* getDragonPointer(Cow* candidate)
If object pointed to by candidate is a Dragon (including an IceDragon), returns a Dragon pointer to the object.
Otherwise, returns nullptr.
Submissions
NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for
your submission! (Note that matching sample output is necessary, but not sufficient, for full credit.)
Files: cowsay.cpp, Cow.cpp, Cow.h, Dragon.cpp, Dragon.h, IceDragon.cpp, IceDragon.h, CMakeLists.txt
Method: Submit on Canvas
Sample Output
finn@BMO:~$ ./cowsay
finn@BMO:~$ ./cowsay Hello World!
Hello World!

^__^
(oo)_______
(__) )/
||‐‐‐‐w |
|| ||
finn@BMO:~$ ./cowsay ‐n kitteh Meow‐Meow!
Meow‐Meow!

(“`‐’ ‘‐/”) .___..‐‐’ ‘ “`‐._
` *_ * ) `‐. ( ) .`‐.__. `)
(_Y_.) ‘ ._ ) `._` ; “ ‐. .‐’
_.. `‐‐’_..‐_/ /‐‐’ _ .’ ,4
( i l ),‐” ( l i),’ ( ( ! .‐’
finn@BMO:~$ ./cowsay ‐n ninja Hello world!
Could not find ninja cow!
finn@BMO:~$ ./cowsay ‐l
Cows available: heifer kitteh dragon ice‐dragon
finn@BMO:~$ ./cowsay ‐n dragon Firey RAWR
Fiery RAWR

|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_’/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _
( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ .‐~~~^‐.
(( / / )) ,‐{ _ `.|.‐~‐. .~ `.
(( // / )) ‘/ / ~‐. _.‐~ .‐~^‐.
(( /// )) `. { } /
(( / )) .‐‐‐‐~‐. ‐’ .~ `. __
///.‐‐‐‐..> _ ‐~ `. ^‐`
///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ `‐‐‐‐‐’
This dragon can breathe fire.
finn@BMO:~$ ./cowsay ‐n ice‐dragon Ice‐cold RAWR
Ice‐cold RAWR

|___/| / //|\
/0 0 __ / // |
/ / /_ / // |
_^_’/ /_ // |
//_^_/ /_ // |
( //) | // |
( / /) _|_ / ) // | _
( // /) ‘/,_ _ _/ ( ; ‐. | _ _.‐~ .‐~~~^‐.
(( / / )) ,‐{ _ `.|.‐~‐. .~ `.
(( // / )) ‘/ / ~‐. _.‐~ .‐~^‐.
(( /// )) `. { } /
(( / )) .‐‐‐‐~‐. ‐’ .~ `. __
///.‐‐‐‐..> _ ‐~ `. ^‐`
///‐._ _ _ _ _ _ _}^ ‐ ‐ ‐ ‐ ~ `‐‐‐‐‐’
This dragon cannot breathe fire.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Cop3504c lab 07: the cow strikes back[SOLVED] Cop3504c lab 07: the cow strikes back
$25