Click here to Skip to main content
15,893,622 members
Articles / Artificial Intelligence

Triangle Peg Solitaire

Rate me:
Please Sign up or sign in to vote.
4.80/5 (7 votes)
22 Oct 2011CPOL4 min read 44.3K   1.4K   7  
This program allows you play Solitaire puzzle also known as Peg Solitaire Puzzle.
package board;


public class Position {
	int row;
	int col;
	
	public Position(int row, int col) {
		this.row = row;
		this.col = col;
	}
	
	public int getRow() { return row; }
	public int getCol() { return col; }

	public String toString() {
		return "[" + row + "," + col + "]";
	}
	
	public int hashCode() {
		int result = 17;
		
		result = 37*result + row;
		result = 37*result + col;
		
		return result;
	}
	
	public boolean equals(Object other) {
		if (!(other instanceof Position))
			return false;
		Position that = (Position) other;
		
		if (this.row != that.row)
			return false;
		
		return this.col == that.col;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions