Class PlugBoard

java.lang.Object
  extended by PlugBoard

public class PlugBoard
extends java.lang.Object

The class PlugBoard implements the plugboard of an Enigma machine. Pairs of letters in the plugboard may get connected by a plug, making a letter get its value spapped by the letter it is plugged to when it passes through the plugboard.

Author:
Lucia Moura

Constructor Summary
PlugBoard()
          the constructor creates an instance of PlugBoard without any plugs.
 
Method Summary
 char outLetter(char letter)
          Method outLetter returns the letter than comes out the plugboard after the given letter enters the plugboard (if the letter has been previously plugged to another its value will be changed to the value of that other letter; otherwise it will be left unchanged)
 void plug(char c1, char c2)
          Method plug connects two letters via a plug if they have not been plugged to any other letter.
 java.lang.String toString()
          This method overrides java.lang.Object.toString() and returns a string representation of this PlugBoard.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlugBoard

public PlugBoard()
the constructor creates an instance of PlugBoard without any plugs.

Method Detail

plug

public void plug(char c1,
                 char c2)
Method plug connects two letters via a plug if they have not been plugged to any other letter. If any of the two letter has already been plugged it does nothing.

Parameters:
c1 - is one of the letters to be plugged to the other.
c2 - is one of the letters to be plugged to the other.

outLetter

public char outLetter(char letter)
Method outLetter returns the letter than comes out the plugboard after the given letter enters the plugboard (if the letter has been previously plugged to another its value will be changed to the value of that other letter; otherwise it will be left unchanged)

Parameters:
letter - is the letter that enters the plugboard
Returns:
is the letter that exits the plugboard

toString

public java.lang.String toString()
This method overrides java.lang.Object.toString() and returns a string representation of this PlugBoard.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this PlugBoard