#include <pets.h>
Public Member Functions | |
Pets () | |
Pets (string filename) throw ( out_of_range, FileNotFound ) | |
void | print (ostream &out=cout) |
void | read (string filename) throw ( out_of_range, FileNotFound ) |
double | getTotalAge () |
~Pets () | |
Private Attributes | |
vector< Pet * > | pets |
Pets::Pets | ( | ) |
Default class constructor.
Pets::Pets | ( | string | filename | ) | throw ( out_of_range, FileNotFound ) |
Explicit class constructor initializing this pets class using the information in the file filename.
filename | a string containing the name of the file to be read |
out_of_range | if a value in the file is out of range | |
FileNotFound | if opening the file fails |
Pets::~Pets | ( | ) |
Destructor.
void Pets::print | ( | ostream & | out = cout |
) |
Prints to the ostream out this object's pets, their names, gender, County ID, weights, and, for guide pets, their Guide-Dog ID. The ostream defaults to cout.
out | an ostream for printing (defaults to cout) |
void Pets::read | ( | string | filename | ) | throw ( out_of_range, FileNotFound ) |
Reads pets from the file named filename
and stores them in a vector. Dog pets are marked with "dog", and all other pets are marked with "cat". If the file fails to open, then it throws a FileNotFound exception. It throws an out_of_range exception if a value in the file is out of range.
filename | a string containing the name of the file to read |
out_of_range | if a value in the file is out of range | |
FileNotFound | if opening the file fails |
double Pets::getTotalAge | ( | ) |
Computes and returns the total age of the pets stored in the vector.
vector<Pet *> Pets::pets [private] |