|
// Includes
#include "stdafx.h"
#include "HighscoreEntry.h"
#include <string>
////////////////////////////////////// Construction /////////////////////////////////
CHighscoreEntry::CHighscoreEntry(long lScore, const CString& strName, long lTime) : m_lScore(lScore), m_strName(strName), m_dtTimeStamp(CTime::GetCurrentTime())
{
if (lTime > 0)
{
m_dtTimeStamp = lTime;
}
else
{
m_dtTimeStamp = CTime::GetCurrentTime();
}
}
CHighscoreEntry::~CHighscoreEntry()
{
}
const CHighscoreEntry& CHighscoreEntry::operator=(const CHighscoreEntry& hse)
{
(*this).m_lScore = hse.m_lScore;
(*this).m_strName = hse.m_strName;
(*this).m_dtTimeStamp = hse.m_dtTimeStamp;
return (*this);
}
CHighscoreEntry::CHighscoreEntry(const CHighscoreEntry& hse)
{
(*this) = hse;
}
////////////////////////////////////// Operators /////////////////////////////////
bool CHighscoreEntry::operator==(const CHighscoreEntry& hse) const
{
return ((*this).m_lScore == hse.m_lScore);
}
bool CHighscoreEntry::operator!=(const CHighscoreEntry& hse) const
{
return !((*this) == hse);
}
bool CHighscoreEntry::operator<(const CHighscoreEntry& hse) const
{
return ((*this).m_lScore < hse.m_lScore);
}
bool CHighscoreEntry::operator>(const CHighscoreEntry& hse) const
{
// yes there's more than one way to do it
// this is better for complex objects usually
return !((*this) < hse || (*this) == hse);
}
bool CHighscoreEntry::operator>=(const CHighscoreEntry& hse) const
{
return ((*this) > hse || (*this) == hse);
}
bool CHighscoreEntry::operator<=(const CHighscoreEntry& hse) const
{
return ((*this) < hse || (*this) == hse);
}
// mainly for testing purposes
ostream& operator<<(ostream& os, const CHighscoreEntry& hse)
{
char* name = new char[100];
ConvertToChar(hse.m_strName, name);
os << name << ' ' << hse.m_lScore << ' ' << hse.m_dtTimeStamp.GetDay() << '/' << hse.m_dtTimeStamp.GetMonth() << '/' << hse.m_dtTimeStamp.GetYear();
delete name;
return os;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software designer and programmer.
Programming languages:
MFC, C++, Java , C#, VB and sometimes C and assembly.