Question: For this assignment, you are to design and implement a Java class named Enigma that simulatesthis three-ring model of an Enigma machine. You may assume

For this assignment, you are to design and implement a Java class named Enigma that simulatesthis three-ring model of an Enigma machine. You may assume that all Enigma models have thesame outer rotor, as shown in the above diagram. That is, the outer rotor consists of the 26capital letters and the '#' symbol (representing a space) in the following clockwise order:

#BDFHJLNPRTVXZACEGIKMOQSUWY. Since the middle and inner rotors are interchangeable, their contents and alignment relative to the outer rotor must be specified when constructing an Enigmamodel. For example, the initial settings of the inner and middle rotors in the above diagram are #GNUAHOVBIPWCJQXDKRYELSZFMT and #EJOTYCHMRWAFKPUZDINSXBGLQV, respectively. Using anEnigma object, it should be possible to both encode and decode text messages, with the appropriate rotation of the rotors occurring after each character encoding/decoding. You should also design and implement a client program. For users who do not want to specify their own rotor settings, have a default option that uses the setting shown in the diagram. In addition, create an option that makes it simple for the user to specify the rotor settings on anEnigma model, and encode or decode text.

Using the outlines provided as a starting point:

Complete all method stubs in the Enigma class (Enigma.java). You are welcome to add

additional methods as needed to facilitate procedural decomposition

Implement a user-friendly client program (EnigmaClient.java)

Provide user instructions fully explaining how to use your program for making yourprogram user-friendly Fully demonstrate the proper functioning of your program by providing samplesinput/output

Here's the template:

public class Enigma {

public static final String outerRotor = "#BDFHJLNPRTVXZACEGIKMOQSUWY";//required instance members go here//for example, all three rotors are declared here//instance member to keep count to move middle rotor

public Enigma(){//default constructor - constructs enigma machine as shown in spec}public Enigma(String s1, String s2){//non-default constructor - constructs machine with user specified

inner and middle rotors

//non-default constructor should call method(s) to make sure rotors

meet requirements}

private boolean isRotorValid (String rotStr){

//verify that rotStr is exactly 27 chars long//verify that all chars from english alphbet occur only once//verify that rotor starts with a # char

}public String encrypt (String message){

//call to encodeChar//call to rotateClockwise

} public String decrypt (String message){//call to rotateAntiClockwise

//call to decodeChar

}private void rotateClockwise(){}private void rotateAntiClockwise(){}public void reset (){

//resets to align all # chars on all rotors (returns rotors to

initial configuration)

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!