, ,

[SOLVED] Cop3504c lab 08: return of the cow

$25

File Name: Cop3504c_lab_08__return_of_the_cow.zip
File Size: 320.28 KB

Categories: , , Tags: , ,
5/5 - (1 vote)

Overview
This lab’s purpose is to provide students with experience in file I/O and C++ exceptions. 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.
Students will need to look up the constructors for some C++ standard objects, such as exceptions, in the C++
documentation to complete this lab. Note that you will need to set the language version to C++17 in your
CMakeLists.txt file for this project.
Specification
Students will update the driver program class (cowsay) and also add one new class – FileCow. The FileCow 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 handle the new FileCow class. (Please refer to specification for previous
lab for a refresher.) Students may implement protected 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!
Cowsay Class (Program Driver)
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 built-in COW
cowsay -f COW MESSAGE Prints out the MESSAGE using the specified file COW
Note that this version of the utility handles a special set of Cow-derived FileCow objects. The HeiferGenerator
will automatically create FileCow objects (using the FileCow constructor) from files in the “cows” directory.
Previous Work
The following classes, developed previously, are required for this lab to function.
Cow
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 (extends Cow)
public Dragon(const string& _name, const string& _image) // Constructor
public bool canBreatheFire() // Defaults to true
>cowsay -l
Regular cows available: heifer kitteh dragon ice-dragon
File cows available: moose turkey turtle tux
IceDragon (extends Dragon)
public Dragon(const string& _name, const string& _image) // Constructor
public bool canBreatheFire() // Returns false
FileCow Class
The FileCow class must be derived from the Cow class. In addition, FileCow must add the following behavior:
public FileCow(const string& _name, const string& filename)
Constructor; creates a new FileCow object with the given name and an image loaded from filename. If the file
cannot be loaded, it should throw a new std::ifstream::failure exception object with the message
“MOOOOO!!!!!!”. This should be the only public constructor for the FileCow class!
public void setImage()
Should throw a new std::runtime_error exception object with message “Cannot reset FileCow Image”.
Submissions
NOTE: Your output must match the example output *exactly*. If it does not, you will not receive full credit for
your submission!
Files: rotc.zip
Method: Submit on Canvas
Compressed Archive (rotc.zip)
We do not list required source files, only headers. You may include any additional source or header files in
addition to those listed, but you must have the listed files at a minimum.
Your compressed file should have the following directory/file structure:
rotc.zip
rotc (directory)
CMakeLists.txt
Cow.h
Dragon.h
FileCow.h
IceDragon.h
(Other sources / folders)
Sample Output
>javac Cowsay.java
>java Cowsay Hello World!
Hello World!

^__^
(oo)_______
(__) )/
||—-w |
|| ||
>java Cowsay -n kitteh Moew-Moew!
Moew-Moew!

(“`-‘ ‘-/”) .___..–‘ ‘ “`-._
` *_ * ) `-. ( ) .`-.__. `)
(_Y_.) ‘ ._ ) `._` ; “ -. .-‘
_.. `–‘_..-_/ /–‘ _ .’ ,4
( i l ),-” ( l i),’ ( ( ! .-‘
>java Cowsay -l
Regular cows available: heifer kitteh dragon ice-dragon
File cows available: moose turkey turtle tux
>java Cowsay -n ninja Hello world!
Could not find ninja cow!
>java Cowsay -f tux Do you have any herring?
Do you have any herring?
.–.
|o_o |
|:_/ |
//
(| | )
/’_ _/`
___)=(___/
>java Cowsay -f alien Earth is ours!
Could not find alien cow!
>java Cowsay -f kitteh MEOW!!!
Could not find kitteh cow!
>java Cowsay -n tux How about tuna?
Could not find tux cow!

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] Cop3504c lab 08: return of the cow[SOLVED] Cop3504c lab 08: return of the cow
$25