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

COVERAGE SUMMARY FOR SOURCE FILE [MiniPuzzle.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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