java.awt.event.ActionListener, java.util.EventListenerTicTacToeHashCodeabstract class Board
extends javax.swing.JFrame
implements java.awt.event.ActionListener
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategyjava.awt.Container.AccessibleAWTContainer| Modifier and Type | Field | Description |
|---|---|---|
private java.lang.String |
boardString |
This String is the String being used as the current TicTacToe String
|
private javax.swing.JButton[][] |
buttons |
The JButton array that displays the TicTacToe board (the xs and os)
|
private javax.swing.JLabel |
lblHashCode |
The label on the graphical interface showing the hash code of the
current TicTacToe String displayed
|
private javax.swing.JLabel |
lblWinTitle |
The label on the graphical interface showing whether the current
TicTacToe String being displayed is a winner or a loser
|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTCROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR| Constructor | Description |
|---|---|
Board(java.lang.String title) |
Constructs a Board using a title.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
This method was required by the superclass, but was not defined because it
was not needed.
|
char |
charAt(int row,
int col) |
Returns the value of the char in buttons at [row, col]
|
char |
charAt(java.lang.String s,
int row,
int col) |
Returns the char in a String, which if it were a 3x3 array, would
be at position [row, col].
|
private static char |
cycleValue(char ch) |
Used to cycle out the values of the board, by replacing certain character
with other certain characters.
|
void |
displayRandomString() |
Displays a random string on the board.
|
java.lang.String |
getBoardString() |
Returns boardString
|
(package private) abstract boolean |
isWin() |
An abstract method that should return whether or not the boardString
is a winning TicTacToe String, hopefully using an array of winners
and hash codes
|
(package private) abstract boolean |
isWin(java.lang.String s) |
An abstract method that should return whether or not the String passed
in is a winning TicTacToe String, hopefully using an array of winners
and hash codes
|
(package private) abstract int |
myHashCode() |
An abstract method that is intended to generate a hash code using
the boardString
|
private char |
randomXO() |
Returns a random option for the TicTacToe board, namely an x, an o,
or a space.
|
void |
resetBoardString() |
Resets the boardString to an empty String
|
void |
setBoardString(java.lang.String s) |
Sets the boardString to s
|
void |
setHashCodeLabel(int hashcode) |
Sets the label for the hashcode using a passed in String.
|
private void |
setupFrame() |
Sets up basic aspects of the frame like size, layout,
and default close operation.
|
(package private) javax.swing.JPanel |
setupPanelOne() |
Creates and returns a JPanel with the correct current hash code,
winner label, and title of the Board.
|
private javax.swing.JPanel |
setupPanelTwo() |
Creates and returns a JPanel to be integrated into the board.
|
void |
setWinnerLabel(boolean result) |
Sets the winner label using a given Boolean.
|
void |
setWinnerLabel(java.lang.String result) |
Sets the label for the winner using a passed in String.
|
void |
show(java.lang.String s) |
Shows the TicTacToe string passed in on the buttons array.
|
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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleadd, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeaddNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecoratedaddImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFrontprivate javax.swing.JButton[][] buttons
private javax.swing.JLabel lblHashCode
private javax.swing.JLabel lblWinTitle
private java.lang.String boardString
public Board(java.lang.String title)
title - the title for hte JFramepublic void setHashCodeLabel(int hashcode)
hashcode - a given integer that is supposed to be the hash codepublic void setWinnerLabel(java.lang.String result)
result - a given String that is supposed to represent whether
the boardString is a winner or a loserpublic void setWinnerLabel(boolean result)
result - a boolean representing the winning statuspublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenere - an ActionEvent that will not have any effect on the program
given the explanation abovejavax.swing.JPanel setupPanelOne()
private javax.swing.JPanel setupPanelTwo()
private static char cycleValue(char ch)
ch - an x, o or space characterprivate void setupFrame()
private char randomXO()
abstract int myHashCode()
abstract boolean isWin(java.lang.String s)
s - the String whose winning status should be determinedabstract boolean isWin()
public char charAt(int row,
int col)
row - the row the char is on in buttonscol - the col the char is on in buttonspublic char charAt(java.lang.String s,
int row,
int col)
s - the String holding the char to be foundrow - the row the char would be oncol - the col the char would be onpublic void show(java.lang.String s)
s - the String to be displayed on the buttonspublic void resetBoardString()
public void setBoardString(java.lang.String s)
s - the String boardString is to be set topublic java.lang.String getBoardString()
public void displayRandomString()