// motor.cpp - Motor class implementation #include "motor.h" // bring in the motor class definition const double MAX_VOLTAGE = 600.0; CMotor::CMotor() { m_voltage = 0; } CMotor::CMotor(const string & idNum, double voltage ) { set_ID(idNum); set_Voltage(voltage); } bool CMotor::set_ID(const string & newID) // Uses boolean return value to indicate input // error. { if( newID.size() == ID_SIZE ) { m_ID = newID; return true; } else return false; } string CMotor::get_ID() const { return m_ID; } void CMotor::set_Voltage(double newVolts) // Displays error message immediately { if( newVolts >= 0 && newVolts <= MAX_VOLTAGE ) m_voltage = newVolts; else cout << "Voltage is out of range and cannot be set.\n"; } double CMotor::get_Voltage() const { return m_voltage; } void CMotor::WriteToFile( ofstream & outfile ) const { outfile << m_ID << "\n" << m_voltage << "\n"; } void CMotor::Display() const { cout <> temp; validID = set_ID(temp); if( !validID ) cout << "Rejected because the ID length was invalid...\n"; } while( !validID ); double v; cout << "Voltage: "; cin >> v; set_Voltage(v); } void CMotor::ReadFromFile(ifstream & infile) { infile >> m_ID >> m_voltage; }