EMMA Coverage Report (generated Fri Mar 15 09:08:15 CET 2013)
[all classes][jpacman.controller]

COVERAGE SUMMARY FOR SOURCE FILE [RandomMonsterMover.java]

nameclass, %method, %block, %line, %
RandomMonsterMover.java100% (3/3)88%  (7/8)84%  (151/179)83%  (19/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RandomMonsterMover100% (1/1)100% (3/3)78%  (69/88)83%  (18.2/22)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
doTick (): void 100% (1/1)78%  (59/76)81%  (15.4/19)
RandomMonsterMover (Engine): void 100% (1/1)100% (4/4)100% (2/2)
     
class RandomMonsterMover$1100% (1/1)100% (1/1)88%  (29/33)87%  (0.9/1)
<static initializer> 100% (1/1)88%  (29/33)87%  (0.9/1)
     
class RandomMonsterMover$Direction100% (1/1)75%  (3/4)91%  (53/58)91%  (0.9/1)
valueOf (String): RandomMonsterMover$Direction 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (44/44)100% (1/1)
RandomMonsterMover$Direction (String, int): void 100% (1/1)100% (5/5)100% (1/1)
values (): RandomMonsterMover$Direction [] 100% (1/1)100% (4/4)100% (1/1)

1package jpacman.controller;
2 
3 
4import jpacman.model.Engine;
5import jpacman.model.Monster;
6 
7/**
8 * Example, simple monster mover that just moves monsters randomly.
9 *
10 * @author Arie van Deursen; Aug 18, 2003
11 * @version $Id: RandomMonsterMover.java,v 1.9 2008/02/08 20:15:19 arie Exp $
12 */
13public class RandomMonsterMover extends AbstractMonsterController {
14 
15    /**
16     * Start a new mover with the given engine.
17     *
18     * @param e
19     *            Engine used.
20     */
21    public RandomMonsterMover(Engine e) {
22        super(e);
23    }
24 
25    /**
26     * Local enum for directions.
27     */
28    private enum Direction { UP, DOWN, LEFT, RIGHT };
29 
30    /**
31     * Actually conduct a random move in the underlying engine.
32     *
33     * @see jpacman.controller.IMonsterController#doTick()
34     */
35    public void doTick() {
36        Monster theMonster = getRandomMonster();
37 
38        int dx = 0;
39        int dy = 0;
40 
41        int dir = getRandomizer().nextInt(Direction.values().length);
42        Direction d = Direction.values()[dir];
43        switch(d) {
44        case UP:
45            dy = -1;
46            break;
47        case DOWN:
48            dy = 1;
49            break;
50        case LEFT:
51            dx = -1;
52            break;
53        case RIGHT:
54            dx = 1;
55            break;
56        default:
57            assert false;
58        }
59 
60        assert dy >= -1 && dy <= 1;
61        assert
62        Math.abs(dx) == 1 && dy == 0
63        ||
64        Math.abs(dy) == 1 && dx == 0;
65 
66        getEngine().moveMonster(theMonster, dx, dy);
67    }
68}

[all classes][jpacman.controller]
EMMA 2.0.5312 (C) Vladimir Roubtsov