walk2d.h
来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 29 行
H
29 行
#ifndef _WALK2D_H
#define _WALK2D_H
#include "point.h"
class RandomWalk2D
{
public:
RandomWalk2D(long maxSteps,
int size); // # of steps, size of one step
void Init(); // take first step of walk
bool HasMore(); // returns false if walk finished, else true
void Next(); // take next step of random walk
void Simulate(); // complete an entire random walk
long TotalSteps() const; // total # of steps taken by molecule
Point Position() const; // current position
Point Current() const; // alias for Position
private:
void TakeStep(); // simulate one step of walk
Point myPosition; // coordinate of current position
long mySteps; // # of steps taken
int myStepSize; // size of step
long myMaxSteps; // maximum # of steps allowed
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?