PlugBoard::PlugBoard( char *pbFileName ) { /* Error and format check file */ Errors checkPlugBoard; checkPlugBoard.noRepContFile( pbFileName, 'p' ); /* Open plugboard file. Loop through the file, counting * the total number of values in the file */ ifstream pbfile; pbfile.open( pbFileName ); int contact; mapLength = 0; // set @mapLength to zero if( pbfile.fail() ){ // Throw error if cannot open throw FileOpenErrExptn( ERROR_OPENING_CONFIGURATION_FILE, pbFileName ); } while( !pbfile.eof() ){ // Loop through file counting values if( !pbfile.eof() ){ pbfile >> contact; mapLength++; } }
Reflector::Reflector( char *rfFileName ) { /* Error and format check file */ Errors checkReflector; checkReflector.noRepContFile( rfFileName, 'f' ); /* Open given reflector file. */ ifstream reflectorFile; reflectorFile.open( rfFileName ); if( reflectorFile.fail() ){ // Throw error if cannot open throw FileOpenErrExptn( ERROR_OPENING_CONFIGURATION_FILE, rfFileName ); } /* Initialize elements of reflectorMap, by convering the * int values from given file into uppercase characters * and assign these characters to elements in @reflectorMap. * Each column contains a 'wired' pair of characters. */ int contactOne; // first value in 'wired' pair from file int contactTwo; // second value in 'wired' pair from file int pair = 0; while( !reflectorFile.eof() ){ reflectorFile >> contactOne; reflectorFile >> contactTwo; if( !reflectorFile.eof() ){ reflectorMap[pair][0] = (contactOne+65); // +65 for u.case convert reflectorMap[pair][1] = (contactTwo+65); pair++; } } }