thanks for any help given.
my code for the class, selection sort function and the display method are below:
void selectionSort()
{
int i, minIndex, minValue;
for (i = 0; i < (arrlength - 1); i++)
{
minIndex = i ;
minValue = player[i].getAge() ;
for (int index = i + 1; index < arrlength; index++)
{
if (player[index].getAge() < minValue)
{
minValue = player[index].getAge();
minIndex = index;
}
}
player[minIndex].setAge(player[i].getAge());
player[i].getAge() == minValue;
}
}
void displayallinfo()
{
selectionSort();
for (int i=0; i < 3; i++)
{
cout << "\n First Name : " << player[i].getFirstName() << "\n" << "Last Name : " << player[i].getLastName() <<
"\n" << "Age : " << player[i].getAge() << "\n" << "Current Team : " << player[i].getCurrentTeam() <<
"\n" << "Position : " << player[i].getPosition() << "\n" << "Status : " << player[i].getStatus() << "\n\n";
}
cin.get() ;
menu() ;
}
class user
{
string firstname, lastname, currentteam, position, status ;
int age ;
public:
user() {};
user(string fname, string lname, string cteam, string pos, string stat, int age)
{
setFirstName(fname);
setLastName(lname);
setCurrentTeam(cteam);
setPosition(pos);
setStatus(stat);
setAge(age);
} ;
user& operator = (const user& source)
{
firstname = source.firstname;
lastname = source.lastname ;
currentteam = source.currentteam ;
position = source.position ;
status = source.status ;
age = source.age ;
}
void setFirstName(string fname)
{firstname = fname;}
void setLastName(string lname)
{lastname = lname;}
void setCurrentTeam(string cteam)
{currentteam = cteam;}
void setPosition(string pos)
{position = pos;}
void setStatus(string stat)
{status = stat;}
void setAge(int _age)
{age = _age;}
string getFirstName()
{return firstname ;}
string getLastName()
{return lastname ;}
string getCurrentTeam()
{return currentteam ;}
string getPosition()
{return position ;}
string getStatus()
{return status ;}
int getAge()
{return age ;}
};

New Topic/Question
Reply



MultiQuote







|