全文链接:http:///?p=29602In this assignment you will write a graphics-based program to do a random walk, sometimes also known as a drunkard’s walk. This random walk simulates the wandering of an intoxicated person on a square street grid. The drunkard will start out in the middle of the grid and will randomly pick one of the four compass directions, and take a step in that direction, then another step from that new location in a random direction, etc. This assignment will give you practice with creating classes, using loops, using the java library for random number generation, doing console-based IO, and drawing to a graphics window. Also you’ll get practice in general program development. AnalysisRandow Walk,即随机游走问题,类似布朗运动,物体在下一刻走动的方向完全是随机的。本题利用随机数生成器来模拟下一刻的方位。框架使用java的awt包实现了UI部分,我们只需要将随机算法加入到提供的框架中。 Tips从测试函数入口入手
因此我们需要实现ImPoint类,以及translate方法,核心代码如下
|
|