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

COVERAGE SUMMARY FOR SOURCE FILE [Food.java]

nameclass, %method, %block, %line, %
Food.java100% (1/1)100% (7/7)72%  (60/83)85%  (13.6/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Food100% (1/1)100% (7/7)72%  (60/83)85%  (13.6/16)
meetPlayer (PlayerMove): boolean 100% (1/1)62%  (20/32)72%  (3.6/5)
Food (): void 100% (1/1)69%  (9/13)89%  (2.7/3)
Food (int): void 100% (1/1)73%  (11/15)93%  (3.7/4)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
foodInvariant (): boolean 100% (1/1)90%  (9/10)90%  (0.9/1)
getPoints (): int 100% (1/1)100% (3/3)100% (1/1)
guestType (): char 100% (1/1)100% (2/2)100% (1/1)

1package jpacman.model;
2 
3/**
4 * Food having a number of calories, which can occupy a cell on the board.
5 *
6 * @author Arie van Deursen; Jul 28, 2003
7 * @version $Id: Food.java,v 1.9 2008/02/07 12:46:27 arie Exp $
8 */
9public class Food extends Guest {
10 
11    /**
12     * Number of points this food element represents.
13     */
14    private int points;
15 
16    /**
17     * Create a new Food element.
18     *
19     * @param p
20     *            Calories of this piece of food.
21     */
22    public Food(int p) {
23        points = p;
24        assert foodInvariant();
25    }
26 
27    /**
28     * Create a simple piece of food of just one point.
29     */
30    public Food() {
31        this(1);
32        assert foodInvariant();
33    }
34 
35    /**
36     * Whatever happens, the amount of food is non-negative.
37     *
38     * @return True iff the food is non-negative and the guest's super invariant
39     *         holds as well.
40     */
41    public boolean foodInvariant() {
42        return guestInvariant() && points >= 0;
43    }
44 
45    /**
46     * Provide the number of calories for this piece of food.
47     *
48     * @return Points of this food element.
49     */
50    public int getPoints() {
51        return points;
52    }
53 
54    /**
55     * The player wants to eat this food cell. Modify the move's state to
56     * reflect the effect this would have. Precondition: the move is in its
57     * initialization stage.
58     *
59     * @see jpacman.model.Guest#meetPlayer(jpacman.model.PlayerMove)
60     * @param theMove the move the player intends to do.
61     * @return True, since such a move is possible.
62     */
63    @Override
64    protected boolean meetPlayer(PlayerMove theMove) {
65        assert foodInvariant();
66        assert theMove != null;
67        assert !theMove.initialized();
68        theMove.setFoodEaten(points);
69        return true;
70    }
71 
72 
73    /**
74     * @see jpacman.model.Guest#guestType()
75     * @return character encoding for food guests.
76     */
77    @Override
78    public char guestType() {
79        return Guest.FOOD_TYPE;
80    }
81 
82}

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