#include <cat.h>
Public Member Functions | |
Cat () | |
Cat (string name, double age, int lives=9) throw ( out_of_range ) | |
void | setLives (int lives) throw ( out_of_range ) |
int | getLives () const |
virtual void | print (ostream &out=cout) const |
virtual void | read (istream &in) throw ( out_of_range ) |
Protected Attributes | |
int | lives |
Cat::Cat | ( | ) |
Default constructor.
Cat::Cat | ( | string | name, | |
double | age, | |||
int | lives = 9 | |||
) | throw ( out_of_range ) |
Explicit class constructor initializing a pet object using the arguments name, age, and lives.
name | a string storing the name of this pet | |
age | an int storing the age of this pet | |
lives | an int storing the lives of this pet |
out_of_range | if age or lives is out of range |
void Cat::setLives | ( | int | lives | ) | throw ( out_of_range ) |
Sets this pet's lives.
lives | an int storing this pet's lives, which must be in {0,...,9}. |
out_of_range | if lives if out of range |
int Cat::getLives | ( | ) | const |
Returns this pet's lives.
void Cat::print | ( | ostream & | out = cout |
) | const [virtual] |
Prints this pet's lives to the ostream out, which defaults to cout.
out | an ostream for printing (defaults to cout) |
Reimplemented from Pet.
void Cat::read | ( | istream & | in | ) | throw ( out_of_range ) [virtual] |
Reads this pet's lives from the istream, storing them in the respective data members.
in | an istream for reading |
out_of_range | if age or lives is out of range |
Reimplemented from Pet.
int Cat::lives [protected] |