#include "cRandom.hpp" /*** ANSI C Header Files ***/ #include #include using MathEngine::cRandom; /*static*/ cRandom* cRandom::sp_inst = nullptr; cRandom::cRandom() { Setup(); } cRandom::~cRandom() {} /// Functions /*static*/ cRandom& cRandom::Inst() { if (sp_inst == nullptr) sp_inst = new cRandom(); return *sp_inst; } /*static*/ void cRandom::Delete() { delete sp_inst; sp_inst = nullptr; } const bool cRandom::Setup() const { bool rtn = false; srand((unsigned int)time(nullptr)); return rtn = true; } const unsigned long int cRandom::Rand( const unsigned long int max, const unsigned long int min /*= 0*/ ) const { return (unsigned long int)rand() % max + min; } const float cRandom::Rand( const float max, const float min /*= 0.0f*/ ) const { return (float)((max - min) * rand()/(float)RAND_MAX + min); }