Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Student.h"
- #include <iostream>
- #include <fstream>
- #include <ctime>
- #include <Windows.h>
- using namespace std;
- Students::Students(){
- keyNumber=0;
- grade=0;
- studentNumber=0;
- for(int i = 0; i <100; i++)
- totalCorrect[i]=2;
- //Seed Random Function
- //Has student randomly guess questions
- ofstream output;
- output.open("Constructor Output.txt",ios::app);
- for(int i=0;i<100;i++)//working
- {
- answers[i]=rand()%5;
- output<<answers[i]<<endl;
- }
- output<<"////////"<<endl;
- output.close();
- //for(int i =4; i<10; i++)
- //cout<<answers[i]<<"//////////////////"<<endl;
- }
- void Students::getVersion(int studentNumber)
- {
- //Sets the keyNumber for the student to determine what test it will be checked against
- keyNumber=studentNumber%4; // working
- ofstream output;
- output.open("getversions output.txt",ios::app);
- output<<keyNumber<<endl;
- output.close();
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////
- void Students::checkAnswers(const int a[100][2]){
- //Variable to hold the test answers
- /*int theKey[100][2];
- for(int i=0;i<100;i++)
- {
- theKey[i][0] = a[i][0];
- theKey[i][1] = a[i][1];
- }
- */
- //checks students answers to key
- ofstream output;
- output.open("Check Answers output.txt",ios::app);
- for(int i=0;i<100;i++)//NOT !!! WORKINGGGGG
- {
- if(answers[i]==a[i][0]||answers[i]==a[i][1])
- {
- totalCorrect[i]=1;
- }
- else
- {
- totalCorrect[i]=0;
- }
- output<<totalCorrect[i]<<endl;
- }
- output<<"///////"<<endl;
- output.close();
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- void Students::checkGrade()
- {
- ofstream output;
- output.open("checkGrades output.txt",ios::app);
- //Calculates the students correct answers
- for(int a=0;a<100;a++)//working
- {
- grade = grade + totalCorrect[a];
- output<<grade<<endl;
- }
- output<<"///////"<<endl;
- output.close();
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- void Students::returnAnswers(int pubAnswers[]){
- //Used to return the students answers so that the main function and access them
- for(int i=0;i<100;i++)//un-used
- {
- pubAnswers[i]=answers[i];
- }
- }
- void Students::printGrades(int pubAnswers[]){
- ofstream output;
- output.open("Grades.txt");
- for(int i=0;i<100;i++)///Come back to us used at the moment
- {
- if(-1>grade<70)
- {
- output<<"Student "<<i<<"'s Grade is a A"<<endl;
- }
- if(69>grade<75)
- {
- output<<"Student "<<i<<"'s Grade is a D"<<endl;
- }
- if(74>grade<80)
- {
- output<<"Student "<<i<<"'s Grade is a C"<<endl;
- }
- if(79>grade<90)
- {
- output<<"Student "<<i<<"'s Grade is a B"<<endl;
- }
- if(89>grade<101)
- {
- output<<"Student "<<i<<"'s Grade is a A"<<endl;
- }
- }
- output.close();
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- int Students::getSN(){
- return keyNumber;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////
- void Students::getCorrect(int pubAnswers[100]){
- for(int i=0;i<100;i++)//working
- pubAnswers[i] = totalCorrect[i];
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- int Students::getGrade(){
- return grade;
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- void Students::StudentWrite(){
- ofstream output;
- output.open("Student correct.txt",ios::app);
- for(int i=0;i<100;i++)
- {
- output<<answers[i]<<" "<<totalCorrect[i]<<endl;
- }
- output<<grade<<endl;
- output<<"/////////////////////////////"<<endl;
- output.close();
- cout<<"done"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement