ITI 1121. Introduction to Computing II - Summer 2015

Assignment 1: Implementing an Enigma Machine (100 points, weight 6.25%)

(Last Modified in June 10, 2015)

Due date: Friday June 12 at 11:59PM.
The assignment must be uploaded on Virtual Campus by the due date.
Late assignments are accepted between 1 min late up to a maximum of 24 hours late and they will receive a 30% penalty.

Learning objectives

This assignment introduces Cryptography, "the practice and study of techniques for secure communication in the presence of third parties (called adversaries)". You will learn about physical encoding devices called Enigma machines and will emulate one specific model of Enigma machine, M3 Enigma Machine, used by the Germans in World War II to transmit secret strategic messages. Besides the above learning objectives, this assignment will make you more aware of how cryptography works by experimenting with a specific type of encoding based on a complex model of character substitution.

Background Information

Enigma machines were electro-mechanical cypher machines used in the last century for encoding and decoding secret messages. Early models appeared in the 1920's and later models were used by the Nazi German government during World War II. A cypher machine encodes a "plain text" into a "cypher text" using certain machine settings only known to the parties that are communicating. Setting the Enigma machine to the initial settings used to encode a "plain text" into the "cypher text", results in retrieving the original text when encoding the "cypher text". However, there were too many initial settings of the machine, so that it should be nearly impossible to discover the settings by trial-and-error.
During the war, British cryptologists at Bletchley park were able to break the Enigma.
Alan Turing was one of these key cryptologists.

There are many resources that talk about the history of Enigma Machines and how they work.
We note some of these resources here.


For this assignment you will implement one type of Enigma Machine called Enigma Machine M3.
Here we summarize the main parts of this physical device. Please, consult illustration here. We will use the wiring of the rotors (I,II, III, IV, V) and reflectors (B, C) of original German Enigma (from

You will be representing the Enigma machine as well as some of its physical parts as variables, objects and classes in our program in order to emulate how it works. You will be able to encode and decode messages as done by Navy M3 Enigma Machine used by the Germans in World War II.


When we think of designing classes to emulate the Enigma machine described above, it is clear that we need a classes for the Enigma machine and some of its parts. We see that input and output and simple wire connections can be accomplished by simple character variables and input and output to various methods; however the more complex scrambling parts that implement permutations (plugboard, rotors, reflector) deserve their own classes.
Thus this assignment has main classes: EnigmaMachine, PlugBoard, Rotor and Reflector.
Auxiliary classes Test and Util help with testing and provide auxiliary functionality.
Please also use class StudentInfo to enter your personal information.

IMPORTANT NOTE (added July 4th):
One of the objectives of the assignment is that you practice with arrays.
Arrays arise naturally as a solution to implement the various permutations ("scrambling") done by the various parts of the machine (rotors, reflector, plugboard).
You are required to use a private array in rotor class to store the rotor wiring for the rotor object that is created.
Example: for rotor type-I you can use a char array, where wiring[0]='E', wiring[1]='K', etc , wiring[25]='J'.
Similarly, plugboard and reflector can have such an array storing their own scrambling information.
Class Util contains auxiliary methods to convert between letters 'A'..'Z' and numbers 0..25 that you may find useful in this context.

Assignment Parts and what to hand in:

  1. EnigmaMachine (35 marks)
    An EnigmaMachine works as described above and has 1 plugboard, 3 rotors which we refer as rotor1, rotor2, rotor3 from right to left, and 1 reflector. The startup code already specify several private instance variables and public methods to be implemented.
    A detailed description of the class and start up code can be found here:
  2. Plugboard (15 marks)
    An EnigmaMachine has one Plugboard.
    Plugboard main methods are plug and outLetter; its auxiliary methods are constructors and toString.
    A detailed description of the class and start up code can be found here:
  3. Rotor (30 marks)
    An EnigmaMachine has 3 Rotors.
    For your convenience Rotor.class startup code contains some class variables/constants for specifying the wiring permutations and notch positions for rotor types I, II, III, IV, V.
    A detailed description of the class and start up code can be found here:
  4. Reflector (15 marks)
    An EnigmaMachine has one Reflector.
    For your convenience Reflector.class startup code contains a class variable/constant for specifying the wiring permutations for Reflector types B and C.
    A detailed description of the class and start up code can be found here:
  5. Auxiliary classes, and are provided here.
    Some tests are provided here and others can be created later for marking purposes.
    For instance, this is a JUnit test for class rotor:

  6. Rules and regulations (5 marks)
    • Please follow the programming requirements:
      Use the classes (and their interface) that we have provided. Our test cases (Test.class plus any extra testing classes provided or created in the future) must work with your classes; for this reason the interface of these classes must not be changed.
      Use an array (26 positions) to store the wiring/permutation used in classes rotor, reflector, plugboard.
    • Please follow the general directives for assignments.
    • You must abide by the following submission instructions:
      Include all your java files into a director called u1234567 where 1234567 is your student id.
      Zip this directory and submit via blackboard.
      The directory must contain the following files (with your implementation):
      • README.txt (relevant information can be added here explaining your solution; which features you know to work or know not to work; any information for the marker relevant to marking)
      • (add implementation to it)
      • (add implementation to it)
      • (add implementation to it)
      • (add implementation to it)
      • (add student information to it)
      • (no changes expected)
      • (no changes expected; grounds for changing include: if your code crashes with Test.class, you may restrict your test to show the parts that are working and add appropriate comments to README.txt
    • The assignment is individual (plagiarism or collaborations towards the solution of the assignment will not be tolerated).
      Read the information on academic fraud below.

Academic fraud

This part of the assignment is meant to raise awareness concerning plagiarism and academic fraud. Please read the following documents.

Cases of plagiarism will be dealt with according to the university regulations.

By submitting this assignment, you acknowledge:

  1. having read the academic regulations regarding academic fraud, and
  2. understanding the consequences of plagiarism