ok here is my other version of it
my header file:
Code:
struct sROUND1
{
int GolferScore;
int CoursePar;
//Initializes a round by asking the user the different values through IO statements
int InitRound();
//Neatly outputs to the screen the different values of the round
void DisplayRound();
// **************** Inspectors and Modifiers, one for each property ******************//
void SetGolferScore(int n) { GolferScore = n; }
int GetGolferScore() { return ( GolferScore ); }
void SetCoursePar(int n) { CoursePar = n; }
int GetCoursePar() { return ( CoursePar ); }
};
MAIN FUNCTION FILE:
Code:
#define MAX 1
void main( void )
{
sROUND1* ptrRound;
int i;
//Allocate space for MAX sROUND1 objects and make ptrRound points to them
for (i=0; i<MAX; i++)
ptrRound[i].InitRound();
for (i=0; i<MAX; i++)
ptrRound[i].DisplayRound();
}
My Functions file:
Code:
int sROUND1::InitRound()
{
int nResult = 0;
//Add your code below
//******* Initializng Variables ********
int x=0, nScore, nPar;
float fHand, fSlope;
char szName[50];
sROUND1 rnd;
//** Taking input from the user **
cout << "\n Enter Golfer Score: ";
cin >> nScore;
while (nScore < 69 || nScore > 130) //Checks if the input is valid
{
cout << " \n Invalid Input, please re-enter: ";
cin >> nScore;
}
rnd.SetGolferScore(nScore); //Copies the contents of nScore into the struct
cout << "\n Enter Course Par: ";
cin >> nPar;
while (nPar < 68 || nPar > 74) //Checks if the input is valid
{
cout << " \n Invalid Input, please re-enter: ";
cin >> nPar;
}
rnd.SetCoursePar(nPar); //Copies the contents of nPar into the struct
return(nResult);
}
void sROUND1::DisplayRound()
{
//Add your code below
sROUND1 rnd;
// cout << "\********** Displaying Data **********\n";
cout << "Golfer Score: " <<rnd.GetGolferScore() << endl; //Displays GolferScore
cout << "Course Par: " <<rnd.GetCoursePar() << endl; //Displays CoursePar
}