Hi Everyone,
I've just started a C++ course and finding myself to be struggling through it worse than i expected. I need to create a coding for this:
class MarClass
{
private:
// Details not shown. An object of this class maintains information for
// each competitor in the form of a name, an identification number and
// the time taken to complete the race.
public:
void Initialise(void);
// Initialises an object by supplying names and identification numbers.
// All times are set to a sentinel value to indicate "no entry".
AnsiString GetName(AnsiString Number);
// Searches for a competitor with this identification number.
// If one is found the name of the competitor is returned.
// Otherwise the string "No such competitor." is returned.
AnsiString GetTime(AnsiString Number);
// Searches for a competitor with this identification number.
// If found returns the time taken in the form "hrs/mins/secs"
// or, if no time has been entered, returns "No time recorded.".
// Otherwise the string "No such competitor." is returned.
AnsiString GetByRank(int Rank);
// As competitors complete the run they are placed in rank order. Rank 1
// corresponds to quickest recorded time, rank 2 to second quickest, etc.
// Two competitors with the same time may be ranked in either order.
// The method returns the identification number of the competitor with
// rank given by the parameter, or the string "No such rank.".
bool SetTime(AnsiString Number, int Hrs, int Mins, int Secs);
// Records the time for competitor with this identification number.
// If there is no such competitor false is returned. Otherwise true
// is returned and the time, given by the parameters, is recorded.
}
I'm looking at it as a mission impossibleAny pointers on an approach? i have got :
class MarClass
{
public: void initialse()
{
int IdNumber;
AnsiString nameOfComp;
numberComp = ReadIntPr “Enter the number of competitors: “
cin>>n;
for (I = 1; I<=n; I++)
{
nameOfComp = ReadStringPr “Enter the name”;
cin>>nameOfComp [Index];
IdNumber = ReadIntPr “Enter the ID number of competitors: “
cin>> IdNumber [Index];
}
}
AnsiString getName( number)
{
for ( I=1; I<=n; I++)
{
if ( number == IdNumber[I])
return name[I];
else
cout<< ”No such competitor”;
}
}
Its too mixed up :S


LinkBack URL
About LinkBacks
Any pointers on an approach? i have got :
Reply With Quote