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

COVERAGE SUMMARY FOR SOURCE FILE [StandardPuzzle.java]

nameclass, %method, %block, %line, %
StandardPuzzle.java100% (1/1)86%  (6/7)99%  (340/344)98%  (40/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StandardPuzzle100% (1/1)86%  (6/7)99%  (340/344)98%  (40/41)
toString (): String 0%   (0/1)0%   (0/4)0%   (0/1)
StandardPuzzle (): void 100% (1/1)100% (9/9)100% (3/3)
create (): Puzzle 100% (1/1)100% (31/31)100% (5/5)
getMaxInt (): int 100% (1/1)100% (2/2)100% (1/1)
getRegions (): Map 100% (1/1)100% (294/294)100% (29/29)
getSize (): int 100% (1/1)100% (2/2)100% (1/1)
getType (): PuzzleTypeEnum 100% (1/1)100% (2/2)100% (1/1)

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.HashMap;
24import java.util.Map;
25 
26/**
27 * STANDARD type puzzle.  9 by 9 cells, divided into thirds vertically and
28 * horizontally.  Each row and each column must contain the digits 1 to 9, as
29 * must each box.
30 * @author <a href="http://sourceforge.net/users/stevensa">Andrew Stevens</a>
31 */
32public class StandardPuzzle extends Puzzle {
33    private static final int SIZE = 9;
34    private static final int BLOCK_SIZE = 3;
35 
36    public static Puzzle create() {
37        Puzzle puzzle = new StandardPuzzle();
38 
39        for (int row = 0; row < SIZE; row++) {
40            for (int column = 0 ; column < SIZE; column++) {
41                puzzle.grid.put(new Coordinate(row, column), 0);
42            }
43        }
44 
45        return puzzle;
46    }
47 
48    /**
49     * Creates a new instance of StandardPuzzle.
50     */
51    public StandardPuzzle() {
52        this.grid = new Grid(SIZE);
53    }
54 
55    public PuzzleTypeEnum getType() {
56        return PuzzleTypeEnum.STANDARD;
57    }
58 
59    public int getMaxInt() {
60        return SIZE;
61    }
62 
63    public Map<String, Region> getRegions() {
64        Map<String, Region> regions = new HashMap<String, Region>();
65 
66        // rows
67        for (int row = 0; row < SIZE; row++) {
68            Region region = new Region("Row " + row);
69            for (int column = 0 ; column < SIZE; column++) {
70                region.add(new Coordinate(row, column));
71            }
72            regions.put("row-" + row, region);
73        }
74        // columns
75        for (int column = 0 ; column < SIZE; column++) {
76            Region region = new Region("Column " + column);
77            for (int row = 0; row < SIZE; row++) {
78                region.add(new Coordinate(row, column));
79            }
80            regions.put("column-" + column, region);
81        }
82        // blocks - 3 x 3 square blocks, each one 3 x 3 cells
83        for (int x = 0; x < BLOCK_SIZE; x++) {
84            for (int y = 0; y < BLOCK_SIZE; y++) {
85                Region region = new Region("Box " + ((x * BLOCK_SIZE) + y));
86                for (int row = x * BLOCK_SIZE; row < (x + 1) * BLOCK_SIZE; row++) {
87                    for (int column = y * BLOCK_SIZE ; column < (y + 1) * BLOCK_SIZE; column++) {
88                        region.add(new Coordinate(row, column));
89                    }
90                }
91                regions.put("box-" + ((x * BLOCK_SIZE) + y), region);
92            }
93        }
94        // super-rows
95        for (int x = 0; x < BLOCK_SIZE; x++) {
96            Region region = new Region("superRow-" + x);
97            for (int row = x * BLOCK_SIZE; row < (x + 1) * BLOCK_SIZE; row++) {
98                region.addAll(regions.get("row-" + row));
99            }
100            regions.put("superRow-" + x, region);
101        }
102        // super-columns
103        for (int x = 0; x < BLOCK_SIZE; x++) {
104            Region region = new Region("superColumn-" + x);
105            for (int column = x * BLOCK_SIZE; column < (x + 1) * BLOCK_SIZE; column++) {
106                region.addAll(regions.get("column-" + column));
107            }
108            regions.put("superColumn-" + x, region);
109        }
110 
111        return regions;
112    }
113    
114    public String toString() {
115        return this.grid.toString();
116    }
117 
118    public int getSize() {
119        return SIZE;
120    }
121 
122}

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