Add project files.

This commit is contained in:
2018-06-25 21:48:45 -04:00
parent b04a25689b
commit 3c1b7d28e8
425 changed files with 35333 additions and 0 deletions
@@ -0,0 +1,47 @@
#include "cRandom.hpp"
/*** ANSI C Header Files ***/
#include <stdlib.h>
#include <time.h>
using MathEngine::cRandom;
/*static*/ cRandom* cRandom::sp_inst = nullptr;
cRandom::cRandom()
{
Setup();
}
cRandom::~cRandom()
{}
/*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);
}