Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Exam.h"
- #include <iostream>
- #include <fstream>
- #include <ctime>
- using namespace std;
- Exam::Exam(){
- correctOver=0;
- for(int x=0;x<2;x++)
- for(int y=0;y<4;y++)
- {
- rightPerSec[x][y] = 0;
- }
- for(int i=0;i<100;i++)
- {
- key[i][0] = rand()%5;
- bool distinct = false;
- while(!distinct)
- {
- key[i][1] = rand()%5;
- if(key[i][0]!=key[i][1])
- distinct = true;
- }
- }
- }
- //////////////////////////////////////////////////////////////////////////////////
- void Exam::writeExam(int a){
- int b = a;
- ofstream output;
- switch(b){
- case 0:
- output.open("Test A.txt");
- break;
- case 1:
- output.open("Test B.txt");
- break;
- case 2:
- output.open("Test C.txt");
- break;
- case 3:
- output.open("Test D.txt");
- break;
- }
- for(int i=0;i<100;i++)
- {
- output<<key[i][0]<<" "<<key[i][1]<<endl;
- }
- output.close();
- cout<<"done"<<endl;
- }
- /////////////////////////////////////////////////////////////////////////////////
- void Exam::getKey(int pub[100][2]){
- for(int i=0;i<100;i++)
- {
- pub[i][0] = key[i][0];
- pub[i][1] = key[i][1];
- }
- }
- /////////////////////////////////////////////////////////////////////////////////
- void Exam::findCorrect(int pubAnswers[100]){
- for(int x=0;x<100;x++)
- {
- correctOver = correctOver + pubAnswers[x];
- cout<<correctOver<<endl;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- void Exam::correctSec(int pubAnswers[100]){
- for(int x=0;x<2;x++)
- for(int y=0;y<4;y++)
- for(int z=0;z<100;z++)
- {
- rightPerSec[x][y] =+ pubAnswers[z];
- }
- }
- /////////////////////////////////////////////////////////////////////////////////
- void Exam::WriteResults(int a){
- int b = a;
- ofstream output;
- switch(b){
- case 0:
- output.open("TestRes A.txt");
- break;
- case 1:
- output.open("TestRes B.txt");
- break;
- case 2:
- output.open("TestRes C.txt");
- break;
- case 3:
- output.open("TestRes D.txt");
- break;
- }
- output<<"The kids got "<<correctOver<<" Answers Correct"<<endl;
- output.close();
- cout<<"done"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement