public class CoinBox
extends javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
CoinBox()
This default constructor creates a new coin box with 10 coins and with the default probability,
and colors.
|
CoinBox(int n)
This special constructor creates a new coin box with a specified number of coins,
and with the default probability, size, and colors.
|
CoinBox(int n,
double p)
This special constructor creates a new coin box with a specified number of coins,
and probability, and with default size 40, head color red, tail color green, and
text color white
|
CoinBox(int n,
double p,
int s)
This special constructor creates a new coin box with a specified number of coins,
probability, and size, and with default head color red, tail color green, and text color white
|
CoinBox(int n,
double p,
int s,
java.awt.Color a,
java.awt.Color b,
java.awt.Color c)
This general constructor creates a new coin box with a specified number of coins,
specified preferred size, a specified probability of heads, and specified head,
tail, and text colors.
|
Modifier and Type | Method and Description |
---|---|
Coin |
getCoin(int i)
This method gets a specified coin.
|
int |
getCoinCount()
Ths method gets the number of coins.
|
java.awt.Color |
getHeadColor()
This method returns the head color.
|
int |
getHeadCount()
This method returns the number of heads
|
double |
getProbability()
This method returns the probability of heads.
|
java.awt.Color |
getTailColor()
This method returns the tail color.
|
int |
getTailCount()
This method returns the number of tails
|
java.awt.Color |
getTextColor()
This method returns the tail color.
|
int[] |
getValues()
This method returns the array of values.
|
int |
getValues(int i)
This method returns the value of an individual coin
|
boolean |
isTossed()
This method returns the state of the all of the coins (tossed or untossed).
|
void |
setCoinCount(int n)
This method sets the number of coins.
|
void |
setColors(java.awt.Color a,
java.awt.Color b,
java.awt.Color c)
This method sets the colors for all of the coins.
|
void |
setHeadColor(java.awt.Color c)
This method sets the head color for all of the coins.
|
void |
setProbability(double p)
This method sets the probability of heads for all of the coins.
|
void |
setTailColor(java.awt.Color c)
This method sets the tail color for all of the coins.
|
void |
setTextColor(java.awt.Color c)
This method sets the text color for all of the coins.
|
void |
setTossed(boolean b)
This method sets the state of the all of the coins (tossed or untossed).
|
void |
setValues(int[] v)
This method sets the array of values.
|
void |
setValues(int i,
int x)
This method sets the value of an individual coin.
|
void |
toss()
This method tosses the coins, setting them to random values, as determined by the
probability of heads for each coin.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public CoinBox(int n, double p, int s, java.awt.Color a, java.awt.Color b, java.awt.Color c)
n
- the number of coins.p
- the probability of headss
- the preferred sizea
- the head color.b
- the tail color.c
- the text colorpublic CoinBox(int n, double p, int s)
n
- the number of coins.p
- the probability of headss
- the preferred size.public CoinBox(int n, double p)
n
- the number of coins.p
- the probability of headspublic CoinBox(int n)
n
- the number of coins.public CoinBox()
public int getCoinCount()
public void setCoinCount(int n)
n
- the number of coins in the coin boxpublic Coin getCoin(int i)
i
- the index of the coin.public void setProbability(double p)
p
- the probability of heads.public double getProbability()
public void setColors(java.awt.Color a, java.awt.Color b, java.awt.Color c)
a
- the head colorb
- the tail colorc
- the text colorpublic void setHeadColor(java.awt.Color c)
c
- the head colorpublic java.awt.Color getHeadColor()
public void setTailColor(java.awt.Color c)
c
- the tail colorpublic java.awt.Color getTailColor()
public void setTextColor(java.awt.Color c)
c
- the text colorpublic java.awt.Color getTextColor()
public void toss()
public int getHeadCount()
public int getTailCount()
public void setTossed(boolean b)
b
- true if the coins are tossed.public boolean isTossed()
public void setValues(int[] v)
v
- the array of valuespublic int[] getValues()
public void setValues(int i, int x)
i
- the indexx
- the value of the coinpublic int getValues(int i)
i
- the index