java.lang.ObjectSameModel
public class SameModel
The Model for the game. Holds all data regarding the game and any associated accessor and mutator methods. Note: The game uses same[][] to store data regarding the boxes, so column and row index positions will will be needed to access the boxes at any given position. I have, however used a single index position to access the boxes, as I originally had same[], but only later chnaged to a same[][]. I have kept the original methods, using 'single index positions', but I have had to convert them to column and row index postions through an additional method, to be able to access the same[][]
Constructor Summary | |
---|---|
SameModel()
A simple constructor that takes no parameters. |
Method Summary | |
---|---|
java.lang.Boolean |
checkMatches(int num)
Searches the matchedBoxes array list for the value the method was called with |
void |
clearMatches()
Clears the matchedBoxes array list |
void |
findNearbyMatches(java.lang.Integer boxNum)
For any given box, the method will fill an array list, matchedBoxes, with all boxes vertically and horizontally adjacent that are of the same colour. |
java.lang.Integer |
getBox(int num)
Returns the Integer stored in the same array of arrays at the index position calculated from the parameter |
int |
getBoxes()
Returns the number boxes in the game |
java.awt.Color |
getColour(int colourNum)
Returns the Color stored at index position of the paramter |
int |
getDimention()
Returns the size of the game |
int |
getHoverScore()
Returns the score for the current set of boxes the mouse is over |
int |
getMatchedBox(int num)
Returns the Game Box index stored at the matchedBoxes index position specified in the parameter |
int |
getMatchedBoxesSize()
Return the size of the matchedBoxes array list |
int |
getNumColours()
Returns the number of colours in the game |
int |
getScore()
Returns the current value of score |
static int |
getTotalColours()
Returns the total number of colours possible in the game |
void |
giveNextHint()
Will search for a set of nearby matches, and if found, then it will stop, so the matchedBoxes array list will contain the indexes for these matches These matches will be used for the hint |
java.lang.Boolean |
isGameOver()
Checks is there are any more group of boxes left and returns boolean |
void |
newGame()
Resets the game, for when a new game needs to be started Is also used when the first game is created, to set some values |
void |
resetHoverScore()
Resets the value of hoverScore back to 0 |
void |
setDimention(int dimention)
Sets the parameter value as the dimention for the next game |
void |
setHoverScore()
Sets the value for hoverScore, which is displayed when the mouse hovers over a set of boxes |
void |
setNumColours(int numColours)
Sets the parameter value as the number of colours for the next game |
void |
shuffleBoxesDown()
This will remove a box from 'sets of boxes', a single box at a time, when called, and shuffling boxes above it down to fill the 'blank' box. |
void |
shuffleBoxesToRight()
Shuffles columns to the right, if any 'blank' columns are found, and the 'blank' column is added to the left most of the game |
void |
test()
Used in the JUnit tests to help setup the game in the correct state |
void |
updateScore()
Updates the score by adding to it the current value of hoverScore |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SameModel()
Method Detail |
---|
public java.lang.Boolean checkMatches(int num)
int
- number to search for in the matchedBoxes array list
public void clearMatches()
public void findNearbyMatches(java.lang.Integer boxNum)
'single
- number index position' of type intpublic java.lang.Integer getBox(int num)
The
- int to be calculated to the index position of same
public int getBoxes()
public java.awt.Color getColour(int colourNum)
Index
- position of the colours array
public int getDimention()
public int getHoverScore()
public int getMatchedBox(int num)
int
- nposition of matchedBoxes
public int getMatchedBoxesSize()
public int getNumColours()
public int getScore()
public static int getTotalColours()
public void giveNextHint()
public java.lang.Boolean isGameOver()
public void newGame()
public void resetHoverScore()
public void setDimention(int dimention)
New
- int value for dimentionpublic void setHoverScore()
public void setNumColours(int numColours)
New
- int value for number of colourspublic void shuffleBoxesDown()
public void shuffleBoxesToRight()
public void test()
public void updateScore()