40 lines
501 B
C++
40 lines
501 B
C++
#ifndef _MUSIC_RANDOM_HP_
|
|
#define _MUSIC_RANDOM_HPP_
|
|
#ifndef _COMMON_STDLIB_HPP_
|
|
#include <common/stdlib.hpp>
|
|
#endif
|
|
|
|
class Random
|
|
{
|
|
public:
|
|
Random(int maxNum=10);
|
|
virtual ~Random();
|
|
void setMax(int maxNum);
|
|
int random(void)const;
|
|
private:
|
|
float mMax;
|
|
};
|
|
|
|
inline
|
|
Random::Random(int maxNum)
|
|
: mMax(maxNum)
|
|
{
|
|
}
|
|
|
|
inline
|
|
Random::~Random()
|
|
{
|
|
}
|
|
|
|
inline
|
|
void Random::setMax(int maxNum)
|
|
{
|
|
mMax=maxNum;
|
|
}
|
|
|
|
inline
|
|
int Random::random(void)const
|
|
{
|
|
return ((float)mMax/RAND_MAX)*(float)rand();
|
|
}
|
|
#endif |