| 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 | |
| 21 | package net.sourceforge.pseudoq.solver; |
| 22 | |
| 23 | import java.util.List; |
| 24 | |
| 25 | import net.sourceforge.pseudoq.model.Grid; |
| 26 | |
| 27 | /** |
| 28 | * Structure representing the solution of a puzzle. Contains the completed |
| 29 | * grid and a list of the steps taken to arrive at the solution. |
| 30 | * @author <a href="http://sourceforge.net/users/stevensa">Andrew Stevens</a> |
| 31 | */ |
| 32 | public class Solution { |
| 33 | /** Creates a new instance of Solution */ |
| 34 | public Solution() { |
| 35 | } |
| 36 | |
| 37 | /** Creates a new instance of Solution */ |
| 38 | public Solution(Grid grid, List<SolutionStep> steps) { |
| 39 | this.grid = grid; |
| 40 | this.steps = steps; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Holds value of property grid. |
| 45 | */ |
| 46 | private Grid grid; |
| 47 | |
| 48 | /** |
| 49 | * Getter for property grid. |
| 50 | * @return Value of property grid. |
| 51 | */ |
| 52 | public Grid getGrid() { |
| 53 | return this.grid; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Setter for property grid. |
| 58 | * @param grid New value of property grid. |
| 59 | */ |
| 60 | public void setGrid(Grid grid) { |
| 61 | this.grid = grid; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Holds value of property steps. |
| 66 | */ |
| 67 | private List<SolutionStep> steps; |
| 68 | |
| 69 | /** |
| 70 | * Getter for property steps. |
| 71 | * @return Value of property steps. |
| 72 | */ |
| 73 | public List<SolutionStep> getSteps() { |
| 74 | return this.steps; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Setter for property steps. |
| 79 | * @param steps New value of property steps. |
| 80 | */ |
| 81 | public void setSteps(List<SolutionStep> steps) { |
| 82 | this.steps = steps; |
| 83 | } |
| 84 | |
| 85 | public String toString() { |
| 86 | StringBuffer retValue = new StringBuffer(); |
| 87 | |
| 88 | retValue.append(this.grid.toString()); |
| 89 | if (this.steps != null) { |
| 90 | for (SolutionStep step : this.steps) { |
| 91 | retValue.append(step.toString()); |
| 92 | retValue.append('\n'); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | return retValue.toString(); |
| 97 | } |
| 98 | |
| 99 | } |