Class World

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--World
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class World
extends Panel

A World is made up from a grid of square-shaped Cells.

Author:
Phil Reakes after Ryan Heise
See Also:
Serialized Form

Nested Class Summary
(package private)  class World.CellListener
           
(package private)  class World.DefaultFrame
          The world is just a GUI component that needs to be added to a window.
(package private)  class World.WorldLayout
           
 
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
World(int colCount, int rowCount, WorldFrame frame)
          Creates a new world with the specified number of columns and rows.
 
Method Summary
 void displayScore()
          Displays the player's score.
 boolean gameIsOver()
          Reveals whether the game is over.
(package private)  Cell getCell(int x, int y)
          Gets the cell at coordinates (x,y).
 int getCellClicks()
          Returns the number of cells the player has clicked.
 int getFlaggedMines()
          Get the number of mines that have been correctly flagged.
 int getFlaggedNonMines()
          Get the number of cells that have been incorrectly flagged.
 void setCellClicks(int clicks)
          Sets the number of cells the player has clicked.
 void setFlaggedMines(int mines)
          Set the number of mines that have been correctly flagged.
 void setFlaggedNonMines(int cells)
          Set the number of cells that have been incorrectly flagged.
 void setGameOver(boolean gameState)
          Sets the game over state to true or false.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

World

public World(int colCount,
             int rowCount,
             WorldFrame frame)
Creates a new world with the specified number of columns and rows. Unlike the previous constructor, this one will not automatically create a new window. The world object created by this constructor is simply a GUI component that can be added to some other window. You should create your own window and add this GUI component to it.

Parameters:
colCount - the number of columns in the world.
rowCount - the number of rows in the world.
frame - a window that you have created to contain this world.
Method Detail

displayScore

public void displayScore()
Displays the player's score.


gameIsOver

public boolean gameIsOver()
Reveals whether the game is over.


getCell

Cell getCell(int x,
             int y)
Gets the cell at coordinates (x,y). The origin (0,0) is in the upper left corner of the world.

Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the cell at position (x,y).

getCellClicks

public int getCellClicks()
Returns the number of cells the player has clicked.


getFlaggedMines

public int getFlaggedMines()
Get the number of mines that have been correctly flagged.

Returns:
the number of mines correctly flagged

getFlaggedNonMines

public int getFlaggedNonMines()
Get the number of cells that have been incorrectly flagged.

Returns:
the number of cells incorrectly flagged

setCellClicks

public void setCellClicks(int clicks)
Sets the number of cells the player has clicked. Not used at the moment but included for completeness.

Parameters:
clicks - the desired number of clicks

setFlaggedMines

public void setFlaggedMines(int mines)
Set the number of mines that have been correctly flagged.


setFlaggedNonMines

public void setFlaggedNonMines(int cells)
Set the number of cells that have been incorrectly flagged.


setGameOver

public void setGameOver(boolean gameState)
Sets the game over state to true or false.

Parameters:
gameState - true if setting game over, false otherwise


Generated by BlueJ