Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------
- // Includes
- //---------------------------
- #include "Time.h"
- //---------------------------
- // Defines
- //---------------------------
- #define GAME_ENGINE (GameEngine::GetSingleton())
- //---------------------------
- // Constructor & Destructor
- //---------------------------
- Time::Time(int hour , int minute , int second):m_Hour(59),m_Minute(59),m_Second(59)
- {
- // nothing to create
- }
- Time::~Time()
- {
- // nothing to destroy
- }
- //---------------------------
- // Methods
- //---------------------------
- // Add here the methods
- void Time::NextHour()
- {
- if(m_Hour<24)
- {
- ++m_Hour;
- }
- else
- {
- m_Hour=0;
- }
- }
- void Time::NextMinute()
- {
- if(m_Minute<60)
- {
- ++m_Minute;
- }
- else
- {
- m_Minute=0;
- }
- }
- void Time::NextSecond()
- {
- if(m_Second<60)
- {
- ++m_Second;
- }
- else
- {
- m_Second=0;
- }
- }
- string Time::ToString()
- {
- string hourstring,minutestring,secondstring;
- if (m_Hour<10)
- {
- hourstring=("0")+m_Hour;
- }
- else
- {
- hourstring=m_Hour;
- }
- if (m_Minute<10)
- {
- minutestring=("0")+m_Minute;
- }
- else
- {
- minutestring=m_Minute;
- }
- if (m_Second<10)
- {
- secondstring=("0")+m_Second;
- }
- else
- {
- secondstring=m_Second;
- }
- return string()+hourstring+(':')+minutestring+(':')+secondstring;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement