Public Member Functions | Protected Attributes | List of all members
Bike Class Reference

#include <bike.h>

Inheritance diagram for Bike:
Delivery Urban

Public Member Functions

 Bike ()
 
 Bike (string id, string name, int gears) throw ( invalid_argument )
 
void setID (string id) throw ( invalid_argument )
 
void setName (string name)
 
void setGears (int gears) throw ( invalid_argument )
 
string getID () const
 
string getName () const
 
int getGears () const
 
virtual void print (ostream &out=cout) const
 
virtual void read (istream &in) throw ( invalid_argument )
 
virtual ~Bike ()
 

Protected Attributes

string id
 
string name
 
int gears
 

Detailed Description

Bike class for storing information about a bike, which has an identifier, a name, and a number of gears.

Author
Mark Maloof
Version
1.0, 1/14/13

Constructor & Destructor Documentation

Bike::Bike ( )

Default constructor.

Bike::Bike ( string  id,
string  name,
int  gears 
)
throw (invalid_argument
)

Explicit class constructor initializing a bike object using the arguments id, name, and number of gears.

Parameters
ida string storing the identifier of this bike
namea string storing the name of this bike
gearsan int storing the number of gears of this bike
Exceptions
invalid_argumentif an argument is invalid
Bike::~Bike ( )
virtual

Destructor. Does nothing but is recommended for classes with virtual methods.

Member Function Documentation

int Bike::getGears ( ) const

Returns this bike's gears.

Returns
a int storing this bike's number of gears
string Bike::getID ( ) const

Returns this bike's ID.

Returns
a string storing this bike's ID
string Bike::getName ( ) const

Returns this bike's name.

Returns
a string storing this bike's name
void Bike::print ( ostream &  out = cout) const
virtual

Prints this bike's name and gears to the ostream out, which defaults to cout.

Parameters
outan ostream for printing (defaults to cout)

Reimplemented in Delivery, and Urban.

void Bike::read ( istream &  in)
throw (invalid_argument
)
virtual

Reads this bike's id, name, and gears from the istream argument, storing them in the respective data members.

Parameters
inan istream for reading

Reimplemented in Delivery, and Urban.

void Bike::setGears ( int  gears)
throw (invalid_argument
)

Sets this bike's gears, which must be in {1, ..., 24}.

Parameters
gearsan int storing this bike's gears
Exceptions
invalid_argumentif the number of gears is invalid
void Bike::setID ( string  id)
throw (invalid_argument
)

Sets this bike's ID, which must have the format [A-Z][0-9][0-9].

Parameters
ida string storing this bike's identifier
Exceptions
invalid_argumentif an argument is invalid
void Bike::setName ( string  name)

Sets this bike's name.

Parameters
namea string storing this bike's name

Member Data Documentation

int Bike::gears
protected
string Bike::id
protected
string Bike::name
protected

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