Class BattleS

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by BattleS
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer

public class BattleS
extends javax.swing.JApplet

See Also:
Serialized Form

Nested Class Summary
 class BattleS.HealthBox
          The healthbox is used to display the headpoints your ships have left before they are sunk
 class BattleS.ImagePanel
          The ImagePanel class is used to draw images to a panel by passing a image
protected  class BattleS.PlayImage
          The PlayImage class is used to create the animation you see throughout the game play
(package private)  class BattleS.SocketThrdServer
          The SocketThrdServer Class, this class is used to create the server object that runs in a thread and continually listens for input from clients taken from the AppletCliSer.java and modified to work with battle ship
 class BattleS.TurnBox
          The class that is used to create the turn box which displays the number of turns you and your opponent have taken
(package private)  class BattleS.UseSocket
          The construction for the Client - UseSocket class that uses a thread to lsiten for input connections Also taken from the AppletCliSer.java exmaple and modified for the battleship game
 
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 BattleS.ImagePanel aircraft
           
 javax.swing.JButton BattleBut
           
 BattleS.ImagePanel battleship
           
 java.awt.Image[] battleshipImages
           
 javax.swing.JLabel BattleSunk
           
 javax.swing.JLabel BattleSunk2
           
 java.net.URL buticon
           
 javax.swing.JButton[][] butspot
           
 javax.swing.JButton[][] butspot1
           
 int bypass
           
 javax.swing.JButton CarrierBut
           
 java.awt.Image[] carrierImages
           
 javax.swing.JLabel CarrierSunk
           
 javax.swing.JLabel CarrierSunk2
           
 java.awt.Image[] clapArray
           
 Grid CompGrid
           
 int counter
           
 BattleS.ImagePanel destroyer
           
 javax.swing.JButton DestroyerBut
           
 java.awt.Image[] destroyerImages
           
 javax.swing.JLabel DestroyerSunk
           
 javax.swing.JLabel DestroyerSunk2
           
 javax.swing.JLabel GameOver
           
 java.awt.Panel gameQuit
           
 javax.swing.JOptionPane gametype
           
 int gtype
           
 BattleS.HealthBox healthbox
           
 javax.swing.JOptionPane historyp
           
 java.applet.AudioClip hit
           
 javax.swing.JRadioButton horizontalButton
           
 java.awt.Image[] imageArray
           
protected  BattleS.PlayImage imagePanel
           
 java.awt.Image imageToDisplay
           
(package private)  java.io.BufferedReader in
           
(package private)  java.io.BufferedReader in2
           
(package private)  boolean isAlive
           
(package private)  boolean isServer
           
 javax.swing.JLabel LastTurn
           
 javax.swing.JLabel LastTurn1
           
 javax.swing.JLabel LastTurn1a
           
 javax.swing.JLabel LastTurna
           
 java.applet.AudioClip lose
           
 java.awt.Image[] loseArray
           
protected  BattleS.PlayImage losePanel
           
 java.awt.Panel LPanel
           
 java.awt.Panel LPanel2
           
 javax.swing.JPopupMenu menu
           
 java.applet.AudioClip missed
           
 int netX
           
 int netY
           
 java.awt.Panel numPanel
           
 java.awt.Panel numPanel2
           
 javax.swing.JLabel Opp
           
 javax.swing.JLabel opready1
           
 javax.swing.JLabel opready2
           
 int[] opshiploc
           
 BattleS.ImagePanel opsunkaircraft
           
 BattleS.ImagePanel opsunkbattle
           
 BattleS.ImagePanel opsunkdestroyer
           
 BattleS.ImagePanel opsunkpatrol
           
 BattleS.ImagePanel opsunksub
           
 javax.swing.JButton otherClasstest
           
(package private)  java.io.PrintWriter out
           
(package private)  java.io.PrintWriter out2
           
 java.awt.Panel p1
           
 java.awt.Panel p2
           
 javax.swing.JPanel panel
           
 BattleS.ImagePanel patrolboat
           
 javax.swing.JButton PatrolBut
           
 javax.swing.JLabel PatrolSunk
           
 javax.swing.JLabel PatrolSunk2
           
 Player Play1
           
 int play1lose
           
 int play1win
           
 Player Play2
           
 int play2lose
           
 int play2win
           
 javax.swing.JLabel Player1
           
 javax.swing.JLabel Player2
           
 Grid PlayerOne
           
 int port
           
 java.awt.Image[] ptboatImages
           
 int rad
           
 javax.swing.JLabel ready1
           
 javax.swing.JLabel ready2
           
(package private)  boolean registering
           
 javax.swing.JOptionPane replay
           
 int ret2
           
 java.net.URL rolloverbut
           
(package private)  java.net.Socket serverSocket
           
 java.awt.Image[] shipArray
           
 java.awt.Button[][] shipbut1
           
 int[][] shiploc
           
 int shipT
           
 int size
           
(package private)  java.net.Socket socket
           
 javax.swing.JLabel StatusL
           
 javax.swing.JLabel StatusT
           
 javax.swing.JButton SubBut
           
 BattleS.ImagePanel submarine
           
 java.awt.Image[] submarineImages
           
 javax.swing.JLabel SubSunk
           
 javax.swing.JLabel SubSunk2
           
 java.applet.AudioClip sunk
           
 java.awt.Image[] sunkshipArray
           
 int tCount
           
 javax.swing.JButton tempButton2
           
 javax.swing.JLabel Title
           
 BattleS.TurnBox turnbox
           
 BattleS.ImagePanel usunkaircraft
           
 BattleS.ImagePanel usunkbattle
           
 BattleS.ImagePanel usunkdestroyer
           
 BattleS.ImagePanel usunkpatrol
           
 BattleS.ImagePanel usunksub
           
 javax.swing.JRadioButton verticalButton
           
 javax.swing.JLabel Waiting
           
 javax.swing.JOptionPane win
           
protected  BattleS.PlayImage winPanel
           
 java.applet.AudioClip won
           
 javax.swing.JLabel you
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
BattleS()
           
 
Method Summary
 void byPass(int k)
          Sets the bypass mode up to skip computer shot
 void gameExit()
          This function exits the game when its called.
 void gameReplay()
          This resets the values in the game so the game can be played over again
 int getbyPass()
          Gets the bypass mode status
 int getCounter()
          Gets the counter number
 int getRadio()
          Gets the radio buttons attribute
 int getShip()
          gets the ship type
 int getShipSize()
          Gets the ship size of the ship stored in temp memory
 int getTurnCounter()
          gets the turn count for each player
 void gui()
          Used to create the Graphics User Interface devised of numerous objects pretaining to ships
 void init()
          The start of the applet where the gui is called and is defined
 void setCounter(int c)
          Sets the counter
 void setRadio(int radio)
          Sets the radio buttons attribute
 void setShip(int type)
          Sets the ships type
 void setShipSize(int s)
          Sets the ship size
 void setTurnCounter()
          Sets the turn counter by incrementing it
 void updateConnected()
           
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, 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, firePropertyChange, firePropertyChange, firePropertyChange, 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, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, 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
 

Field Detail

PlayerOne

public Grid PlayerOne

CompGrid

public Grid CompGrid

Play1

public Player Play1

Play2

public Player Play2

butspot

public javax.swing.JButton[][] butspot

butspot1

public javax.swing.JButton[][] butspot1

shipbut1

public java.awt.Button[][] shipbut1

CarrierSunk

public javax.swing.JLabel CarrierSunk

BattleSunk

public javax.swing.JLabel BattleSunk

PatrolSunk

public javax.swing.JLabel PatrolSunk

SubSunk

public javax.swing.JLabel SubSunk

DestroyerSunk

public javax.swing.JLabel DestroyerSunk

CarrierSunk2

public javax.swing.JLabel CarrierSunk2

BattleSunk2

public javax.swing.JLabel BattleSunk2

PatrolSunk2

public javax.swing.JLabel PatrolSunk2

SubSunk2

public javax.swing.JLabel SubSunk2

DestroyerSunk2

public javax.swing.JLabel DestroyerSunk2

Player1

public javax.swing.JLabel Player1

Waiting

public javax.swing.JLabel Waiting

Player2

public javax.swing.JLabel Player2

Opp

public javax.swing.JLabel Opp

you

public javax.swing.JLabel you

Title

public javax.swing.JLabel Title

ready1

public javax.swing.JLabel ready1

ready2

public javax.swing.JLabel ready2

opready1

public javax.swing.JLabel opready1

opready2

public javax.swing.JLabel opready2

LastTurn

public javax.swing.JLabel LastTurn

LastTurna

public javax.swing.JLabel LastTurna

LastTurn1

public javax.swing.JLabel LastTurn1

LastTurn1a

public javax.swing.JLabel LastTurn1a

StatusL

public javax.swing.JLabel StatusL

StatusT

public javax.swing.JLabel StatusT

GameOver

public javax.swing.JLabel GameOver

horizontalButton

public javax.swing.JRadioButton horizontalButton

verticalButton

public javax.swing.JRadioButton verticalButton

rad

public int rad

shipT

public int shipT

size

public int size

counter

public int counter

tCount

public int tCount

bypass

public int bypass

play1win

public int play1win

play1lose

public int play1lose

play2win

public int play2win

play2lose

public int play2lose

CarrierBut

public javax.swing.JButton CarrierBut

BattleBut

public javax.swing.JButton BattleBut

PatrolBut

public javax.swing.JButton PatrolBut

SubBut

public javax.swing.JButton SubBut

DestroyerBut

public javax.swing.JButton DestroyerBut

tempButton2

public javax.swing.JButton tempButton2

otherClasstest

public javax.swing.JButton otherClasstest

p1

public java.awt.Panel p1

p2

public java.awt.Panel p2

gameQuit

public java.awt.Panel gameQuit

win

public javax.swing.JOptionPane win

replay

public javax.swing.JOptionPane replay

historyp

public javax.swing.JOptionPane historyp

panel

public javax.swing.JPanel panel

hit

public java.applet.AudioClip hit

missed

public java.applet.AudioClip missed

won

public java.applet.AudioClip won

lose

public java.applet.AudioClip lose

sunk

public java.applet.AudioClip sunk

buticon

public java.net.URL buticon

rolloverbut

public java.net.URL rolloverbut

imagePanel

protected BattleS.PlayImage imagePanel

winPanel

protected BattleS.PlayImage winPanel

losePanel

protected BattleS.PlayImage losePanel

carrierImages

public java.awt.Image[] carrierImages

battleshipImages

public java.awt.Image[] battleshipImages

submarineImages

public java.awt.Image[] submarineImages

ptboatImages

public java.awt.Image[] ptboatImages

destroyerImages

public java.awt.Image[] destroyerImages

healthbox

public BattleS.HealthBox healthbox

turnbox

public BattleS.TurnBox turnbox

imageToDisplay

public java.awt.Image imageToDisplay

imageArray

public java.awt.Image[] imageArray

shipArray

public java.awt.Image[] shipArray

sunkshipArray

public java.awt.Image[] sunkshipArray

clapArray

public java.awt.Image[] clapArray

loseArray

public java.awt.Image[] loseArray

aircraft

public BattleS.ImagePanel aircraft

battleship

public BattleS.ImagePanel battleship

destroyer

public BattleS.ImagePanel destroyer

submarine

public BattleS.ImagePanel submarine

patrolboat

public BattleS.ImagePanel patrolboat

menu

public javax.swing.JPopupMenu menu

usunkaircraft

public BattleS.ImagePanel usunkaircraft

usunkbattle

public BattleS.ImagePanel usunkbattle

usunksub

public BattleS.ImagePanel usunksub

usunkdestroyer

public BattleS.ImagePanel usunkdestroyer

usunkpatrol

public BattleS.ImagePanel usunkpatrol

opsunkaircraft

public BattleS.ImagePanel opsunkaircraft

opsunkbattle

public BattleS.ImagePanel opsunkbattle

opsunksub

public BattleS.ImagePanel opsunksub

opsunkdestroyer

public BattleS.ImagePanel opsunkdestroyer

opsunkpatrol

public BattleS.ImagePanel opsunkpatrol

numPanel

public java.awt.Panel numPanel

numPanel2

public java.awt.Panel numPanel2

LPanel

public java.awt.Panel LPanel

LPanel2

public java.awt.Panel LPanel2

gametype

public javax.swing.JOptionPane gametype

gtype

public int gtype

shiploc

public int[][] shiploc

opshiploc

public int[] opshiploc

netX

public int netX

netY

public int netY

ret2

public int ret2

socket

java.net.Socket socket

serverSocket

java.net.Socket serverSocket

out

java.io.PrintWriter out

in

java.io.BufferedReader in

out2

java.io.PrintWriter out2

in2

java.io.BufferedReader in2

isServer

boolean isServer

registering

boolean registering

isAlive

boolean isAlive

port

public int port
Constructor Detail

BattleS

public BattleS()
Method Detail

init

public void init()
The start of the applet where the gui is called and is defined

Overrides:
init in class java.applet.Applet

gui

public void gui()
Used to create the Graphics User Interface devised of numerous objects pretaining to ships


setRadio

public void setRadio(int radio)
Sets the radio buttons attribute

Parameters:
radio - - the value of the radio button either 1 or 2

getRadio

public int getRadio()
Gets the radio buttons attribute

Returns:
the value of the radio button

setShip

public void setShip(int type)
Sets the ships type

Parameters:
type - - the type of ship is set here

getShip

public int getShip()
gets the ship type

Returns:
the type of the ship requested

setShipSize

public void setShipSize(int s)
Sets the ship size

Parameters:
s - - the size of the ship being temporay stored

getShipSize

public int getShipSize()
Gets the ship size of the ship stored in temp memory

Returns:
the size of the ship

setCounter

public void setCounter(int c)
Sets the counter

Parameters:
c - - the current count

getCounter

public int getCounter()
Gets the counter number

Returns:
returns the counter number in memory

setTurnCounter

public void setTurnCounter()
Sets the turn counter by incrementing it


getTurnCounter

public int getTurnCounter()
gets the turn count for each player

Returns:
returns the turn count

byPass

public void byPass(int k)
Sets the bypass mode up to skip computer shot

Parameters:
k - - the bypass mode

getbyPass

public int getbyPass()
Gets the bypass mode status

Returns:
returns the bypass mode

gameReplay

public void gameReplay()
This resets the values in the game so the game can be played over again


gameExit

public void gameExit()
This function exits the game when its called. It makes the game over jlabel visible


updateConnected

public void updateConnected()