Computer Science 2574 |
Intro to Data Structures & Soft Eng
|
#include "CourseKeys.h" //*********************************************************************************** // Function: CopyCrseInfo // Parameters: NumStudents - integer value, number of students for test // inFile - infile from which information is read and stored from // // Purpose: to read in course info // Called By: EditMenu, BuildODB // Calls: NONE // Return Value: void // Authors: John W. Boyd III & Cullen J. Morris // Version: 1.1 //*********************************************************************************** void CopyCrseInfo(int& NumStudents, ifstream &inFile, ofstream &outFile) { char buffer[10], line[100]; inFile.getline(line, 150); outFile << line << endl; inFile.getline(line, 150); outFile << line << endl; for(int i = 29; i < 40; i++) //get num students { if(isdigit(line[i])) break; } buffer[0] = line[i]; int j = 0; for(i = i ; i < 40; i++) { if(!(isdigit(line[i]))) break; buffer[j] = line[i]; j++; } inFile.ignore(200, '\n'); inFile.ignore(200, '\n'); NumStudents = atoi(buffer); } //end of CopyCrseInfo //******************************************************************************* // Function: getNumKeys // Purpose: To count the number of keys // Called By: BuildODB // Calls: ResetMarker // Parameters: NumKeys - integer value of Number of Keys, passes out so other // functions know how many keys // inFileDecode - input file, Decodefile(raw) // Return Value: int zero // Authors: John W. Boyd III & Cullen J. Morris // Version: 1.1 //******************************************************************************* int getNumKeys(int &NumKeys,ifstream &inFileDecode) { char SocSecNum[SSLength]; inFileDecode.get(SocSecNum, 10); while (strcmp(SocSecNum,"999999999") == 0) // makes sure it is a answer key { NumKeys++; inFileDecode.ignore(350,'\n'); inFileDecode.get(SocSecNum, 10); } ResetMarker(inFileDecode); inFileDecode.ignore(350,'\n'); inFileDecode.ignore(350,'\n'); return 0; } //******************************************************************************* // Function: getKeys // Purpose: To read in the keys from the decode file. // Called By: BuildODB // Calls: NONE // Parameters: outFile - output file, ODB file we create // inFileDecode - input file to read in from the RAW decode file // NumQuestions - Number of quetions on test // // Return Value: void // Authors: John W. Boyd III & Cullen J. Morris // Version: 1.1 //******************************************************************************* #include "constants.h" void getKeys(ofstream &outFile, ifstream &inFileDecode, int NumQuestions) { char SocSecNum[SSLength], FormCh, GroupCh, AnswerCh; while(inFileDecode) // until EOF { inFileDecode.get(SocSecNum, 10); if( strcmp(SocSecNum,"999999999") != 0) // makes sure it is an answer key { for(int i=8;i>=0;i--) // puts ssn back in infile { inFileDecode.putback(SocSecNum[i]); } break; } outFile << setw(9) << SocSecNum; inFileDecode.get(FormCh); switch (FormCh) // changes form ch from num. to letters { case ' ': FormCh = '9'; break; case '0': FormCh = 'A'; break; case '1': FormCh = 'B'; break; case '2': FormCh = 'C'; } outFile << " " << FormCh; inFileDecode.get(GroupCh); switch (GroupCh) // puts offset on groupch { case ' ': GroupCh = '-'; break; case '0': GroupCh = '1'; break; case '1': GroupCh = '2'; break; case '2': GroupCh = '3'; } outFile << " " << GroupCh << " "; for (int i =0; i < NumQuestions; i++) // goes thru every answer { inFileDecode.get(AnswerCh); switch (AnswerCh) // takes care of omitted and double answered questions { case ' ': AnswerCh = '?'; break; case '*': AnswerCh = '*'; break; } outFile << AnswerCh; } //ends for loop inFileDecode.ignore(350,'\n'); outFile << endl; } // ends while loop } //end of getKeys