EMMA Coverage Report (generated Sat Apr 29 12:52:00 BST 2006)
[all classes][net.sourceforge.pseudoq.model]

COVERAGE SUMMARY FOR SOURCE FILE [Puzzle.java]

nameclass, %method, %block, %line, %
Puzzle.java100% (1/1)100% (12/12)100% (131/131)100% (29/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Puzzle100% (1/1)100% (12/12)100% (131/131)100% (29/29)
Puzzle (): void 100% (1/1)100% (11/11)100% (3/3)
getFilename (): String 100% (1/1)100% (3/3)100% (1/1)
getGivens (): Set 100% (1/1)100% (3/3)100% (1/1)
getGrid (): Grid 100% (1/1)100% (3/3)100% (1/1)
getSolution (): Solution 100% (1/1)100% (3/3)100% (1/1)
isComplete (): boolean 100% (1/1)100% (10/10)100% (1/1)
isPlayed (): boolean 100% (1/1)100% (33/33)100% (6/6)
isSolved (): boolean 100% (1/1)100% (7/7)100% (1/1)
reset (): void 100% (1/1)100% (24/24)100% (5/5)
resetToGivens (): void 100% (1/1)100% (26/26)100% (5/5)
setFilename (String): void 100% (1/1)100% (4/4)100% (2/2)
setSolution (Solution): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright (c) 2005 The PseudoQ Project.
3 *
4 * This file is part of PseudoQ.
5 *
6 * PseudoQ is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * PseudoQ is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with PseudoQ; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20 
21package net.sourceforge.pseudoq.model;
22 
23import java.util.Map;
24import java.util.Set;
25import java.util.HashSet;
26 
27import net.sourceforge.pseudoq.solver.Solution;
28 
29/**
30 * Abstract superclass of all types of puzzle.
31 * @author <a href="http://sourceforge.net/users/stevensa">Andrew Stevens</a>
32 */
33public abstract class Puzzle {
34    protected Grid grid;
35    protected Set<Coordinate> givens = (Set<Coordinate>) new HashSet<Coordinate>();
36    protected Solution solution = null;
37    /**
38     * Holds value of property filename.
39     */
40    private String filename;
41 
42    public abstract PuzzleTypeEnum getType();
43 
44    public Grid getGrid() {
45        return grid;
46    }
47 
48    public Set<Coordinate> getGivens() {
49        return givens;
50    }
51 
52    public abstract int getMaxInt();
53 
54    public abstract int getSize();
55 
56    public abstract Map<String, Region> getRegions();
57 
58    /**
59     * Getter for property solution.
60     * @return Value of property solution.
61     */
62    public Solution getSolution() {
63        return solution;
64    }
65 
66    /**
67     * Setter for property solution.
68     * @param solution New solution.
69     */
70    public void setSolution(Solution solution) {
71        this.solution = solution;
72    }
73 
74    /**
75     * Getter for property filename.
76     * @return Value of property filename.
77     */
78    public String getFilename() {
79        return this.filename;
80    }
81 
82    /**
83     * Setter for property filename.
84     * @param filename New value of property filename.
85     */
86    public void setFilename(String filename) {
87        this.filename = filename;
88    }
89 
90    /**
91     * Whether the grid is completely filled.
92     */
93    public boolean isComplete() {
94        return !grid.containsValue(Integer.valueOf(0));
95    }
96 
97    /**
98     * Whether a solution for the puzzle has been found.
99     */
100    public boolean isSolved() {
101        return (solution != null);
102    }
103 
104    /**
105     * Whether the grid contains values other than those which were given.
106     */
107    public boolean isPlayed() {
108        boolean played = false;
109        for (Coordinate coord : grid.keySet()) {
110            if (!grid.get(coord).equals(Integer.valueOf(0)) &&
111                    !givens.contains(coord)) {
112                played = true;
113            }
114        }
115        return played;
116    }
117 
118    /**
119     * Reset the grid to an empty state.
120     */
121    public void reset() {
122        for (Coordinate coord : grid.keySet()) {
123            grid.put(coord, Integer.valueOf(0));
124        }
125        givens.clear();
126    }
127 
128    /**
129     * Reset the grid to only the given values.
130     */
131    public void resetToGivens() {
132        for (Coordinate coord : grid.keySet()) {
133            if (!givens.contains(coord)) {
134                grid.put(coord, Integer.valueOf(0));
135            }
136        }
137    }
138 
139}

[all classes][net.sourceforge.pseudoq.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov