|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--Cell
A World is made up of a 2-dimensional grid of Cells. Each Cell is square in shape.
Field Summary |
Fields inherited from class java.awt.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Cell(World world,
int xpos,
int ypos)
Constructs a new Cell in the specified World. |
Method Summary | |
void |
addMarker()
Adds a flag type marker to the Cell. |
void |
addMine()
Adds a mine to the Cell. |
void |
cascade()
Clear all adjacent cells if they are completely empty. |
void |
clear()
Clears a non-mined Cell. |
void |
cycleMarker()
Get a reference to the marker on this Cell. |
int |
getAdjacentMarkers()
Gets the number of markers adjacent to the Cell. |
int |
getAdjacentMineNumbers()
Gets the number of 'mine numbers' adjacent to the Cell. |
int |
getAdjacentMines()
Gets the number of mines adjacent to the Cell. |
Marker |
getMarker()
Get a reference to the marker on this Cell. |
Mine |
getMine()
Get a reference to the mine on this Cell. |
Cell |
getNextCell(Direction direction)
Gets the reference to a neighbouring Cell in the specified direction. |
Point |
getPosition()
Gets the location of this Cell. |
Dimension |
getPreferredSize()
This method lets the layout manager know what size this Cell would prefer to be. |
World |
getWorld()
Get a reference to the World containing this Cell. |
boolean |
hasMarker()
Reveals whether the Cell contains a marker or not. |
boolean |
hasMine()
Reveals whether the Cell contains a mine or not. |
boolean |
isClear()
Reveals whether the Cell is clear or not. |
void |
paintMineNumberColour()
Paints a Cell's 'mine number colour' on that Cell. |
void |
removeMarker()
Removes a marker from the Cell. |
void |
removeMine()
Removes a mine from the Cell. |
String |
toString()
Creates a String representation of this Cell. |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Cell(World world, int xpos, int ypos)
world
- the World this Cell will be a part of.xpos
- the x coordinate of the Cell.ypos
- the y coordinate of the Cell.Method Detail |
public void addMarker()
public void addMine()
public void cascade()
public void clear()
public void cycleMarker()
public int getAdjacentMarkers()
public int getAdjacentMineNumbers()
public int getAdjacentMines()
public Marker getMarker()
public Mine getMine()
public Cell getNextCell(Direction direction)
direction
- the direction in which to grab the neighboring Cell.
The Direction will be automatically rounded to the nearest Cell.
public Point getPosition()
public Dimension getPreferredSize()
getPreferredSize
in class Container
public World getWorld()
public boolean hasMarker()
public boolean hasMine()
public boolean isClear()
public void paintMineNumberColour()
Key to 'mine colours':
Orange - 1 mine adjacent. Yellow - 2 mines adjacent. Green - 3 mines adjacent. Cyan - 4 mines adjacent. Blue - 5 mines adjacent. Magenta - 6 mines adjacent. Dark Grey - 7 mines adjacent. Black - 8 mines adjacent.
public void removeMarker()
public void removeMine()
public String toString()
toString
in class Component
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |