#include <bike.h>
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 |
Bike class for storing information about a bike, which has an identifier, a name, and a number of gears.
| 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. Indirectly throws an exception if an argument is invalid.
| id | a string storing the identifier of this bike |
| name | a string storing the name of this bike |
| gears | an int storing the number of gears of this bike |
| invalid_argument | if an argument is invalid |
|
virtual |
Destructor. Does nothing but is recommended for classes with virtual methods.
| int Bike::getGears | ( | ) | const |
Returns this bike's gears.
| string Bike::getID | ( | ) | const |
Returns this bike's ID.
| string Bike::getName | ( | ) | const |
Returns this bike's name.
|
virtual |
|
virtual | ||||||||||||||
Reads this bike's id, name, and gears from the istream argument, storing them in the respective data members. Indirectly throws an exception if an argument is invalid.
| in | an istream for reading |
| invalid_argument | if an argument in the stream is invalid |
| void Bike::setGears | ( | int | gears | ) | |
| throw | ( | invalid_argument | |||
| ) | |||||
Sets this bike's gears, which must be in {1, ..., 24}. Directly throws an exception if the argument is invalid.
| gears | an int storing this bike's gears |
| invalid_argument | if 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]. Directly throws an exception if the argument is invalid.
| id | a string storing this bike's identifier |
| invalid_argument | if the argument is invalid |
| void Bike::setName | ( | string | name | ) |
Sets this bike's name.
| name | a string storing this bike's name |
|
protected |
|
protected |
|
protected |
1.8.6