?? rand.cpp
字號:
// Rand.cpp: implementation of the Rand class.
//
//////////////////////////////////////////////////////////////////////
#include <stdafx.h> // Added 980901 by Aleksander 踙rn.
#include "../copyright.h" // Added 000323 by Aleksander 豩rn.
#include <kernel/basic/message.h>
#include "Rand.h"
RNG Rand::rngInstance = RNG();
RNG * Rand::rng = NULL;
long Rand::seed = 12345;
int Rand::MaxInt = 0x7fff;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Rand::Rand()
{
}
Rand::~Rand()
{
}
double Rand::d()
{
if(rng == NULL){
rng = &rngInstance;
rng->SetSeed(Rand::seed);
}
return (double)rng->DrawFloat();
}
int Rand::i(int upper)
{
if(rng == NULL){
rng = &rngInstance;
rng->SetSeed(Rand::seed);
}
return rng->DrawInteger(0, upper);
}
void Rand::setSeed(long seed)
{
Rand::seed = seed;
if(rng == NULL){
rng = &rngInstance;
rng->SetSeed(Rand::seed);
Message::Debug(String("Setting random seed to ") + String::Format(Rand::seed));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -