Pets Class Reference

#include <pets.h>

List of all members.

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


Detailed Description

The Pets class, derived through private inheritance from the vector class, stores information about pets. The vector stores pointers to these objects, and provides methods for destructing, reading, printing, and totaling the volume of such objects.

Author:
Mark Maloof
Version:
1.1, 7/21/10

Constructor & Destructor Documentation

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.

Parameters:
filename a string containing the name of the file to be read
Exceptions:
out_of_range if a value in the file is out of range
FileNotFound if opening the file fails

Pets::~Pets (  ) 

Destructor.


Member Function Documentation

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.

Parameters:
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.

Parameters:
filename a string containing the name of the file to read
Exceptions:
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.

Returns:
a double storing the total age of the pets


Member Data Documentation

vector<Pet *> Pets::pets [private]


The documentation for this class was generated from the following files:

Generated on Thu Jul 29 11:29:33 2010 by  doxygen 1.5.5