/** * 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 * */ public class PlugBoard { // ADD YOUR PRIVATE VARIABLES HERE /** * the constructor creates an instance of PlugBoard * without any plugs. */ public PlugBoard() { // ADD YOUR CODE HERE } /** * 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. * * @param c1 is one of the letters to be plugged to the other. * @param c2 is one of the letters to be plugged to the other. */ public void plug (char c1, char c2) { // ADD YOUR CODE HERE } /** * 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) * * @param letter is the letter that enters the plugboard * @return is the letter that exits the plugboard */ public char outLetter(char letter) { // ADD YOUR CODE HERE // it is now incorrectly always returning letter A return 'A'; } /** * This method overrides java.lang.Object.toString() and * returns a string representation of this PlugBoard. * * @return a string representation of this PlugBoard */ public String toString() { // Here you must conform to the following standard return string: // return the string "Plugboard:" concatenated with a a string // of 26 characters corresponding to letters 'A'..'Z' that has '*' // at positions that are not plugged and has the corresponding // plugged letter at positions that are plugged. // ADD YOUR CODE HERE // currently returning garbage String s = new String("GARBAGE"); return "Plugboard:"+s; } };