” CS 2113程序 写作、 辅导Java编程Lab 5: Enigma | CS 2113 Software EngineeringPreliminariesGithub LinkAccept this assignment here: httpss://classroom.github.com/a/Nn5yicQDevelopmentEnvironmentThis lab can be developed locally on your machine using any java installation or on replit.Running/Compile your programYou should compile your Program using javac and run it with java . The specific command line arguments areprovided below.Testing your labWe have provided you with a test.sh file to help you test your program.Enigma Machines (simplified model)The Enigma machine was used by the Germans in WWII to send encoded messages. At the time, it was abreakthrough in cryptography, and was essentially an extremely advanced substitution cipher. The Enigma machineis also famous for not just being a very advanced cipher, but also because it was broken by none other than AlanTurning, whom many consider the founder of computer science.In this lab, we will model a Simplified version of the Enigma machine. If youre interested in learning more, Prof.Gavin Taylor (USNA) has a comprehensive write up on the topic. (More details and an image are found at the end ofthis lab.)What you need to know for this labWhat you need to know for this lab: Enigma machines used interchangeable rotors that could be placed in differentorientations to obtain different substitution patterns. More significantly, the rotors rotated after each character wasencoded, changing the substitution Pattern and making the code very difficult to break. The behavior of therotating rotors can be modeled, in a simplified form, by a device consisting of labeled, concentric rings. Forexample, the picture here has three rings labeled with the letters of the alphabet and # (representing a space).To encrypt a character using this model, find the character on the inner rotor (i.e., the inside ring) and note thecharacter aligned with it on the outer rotor (i.e., the outside ring), then find that character on the middle rotor (i.e.,the middle ring) and output the one aligned with it on the outer rotor. After a character is encrypted, turn the innerrotor clockwise one step. Whenever the inner rotor returns to its original orientation, the middle rotor turns once inlock-step, just like the odometer in a car.CS2113SoftwareEngineering-Spring20213/21/2021 Lab 5: Enigma | CS 2113 Software Engineering – Spring 2021 httpss://cs2113-s21.github.io/lab/5 2/4For example, in this configuration the character A would be encrypted as N, since A on the inner rotor is alignedwith H on the outer rotor, and H on the middle rotor is aligned with N on the outer rotor. After performing thisencryption, the inner rotor is rotated clockwise, so the letter A would next be encrypted as D.Note that decrypting a message requires following the same steps, only in reverse: Find the character on the outerrotor, note the character aligned with it on the middle rotor, find that character on the outer rotor, then output thecharacter aligned with it on the inner rotor. Dont forget to rotate the rotors after each letter is decrypted.Task RequirementsThe TaskYou will define a class Rotor to simulate the workings of a single rotor, and the class Enigma to simulate theworkings of an Enigma machine using Rotor instances. You will be provided a class Comms (with a mainmethod) as part of the initial material. You should read that file to see how Enigma instances are suppose to beused.You may not alter Comms.java in any way.Your task is to write both Enigma and Rotor using proper OOP design with class constructors, informationhiding, and encapsulation.The Rotor ClassThe Rotor class represents a rotor, Including the values of the characters in the rotor and its current orientation(which character is currently on top of the rotor). A good strategy for representing this would be to store thecharacters in a String of length 27 ( # indicating space) index 0 is the top most character. Note thatRotors rotate! And after a full rotation, the next outer rotate rotates (like a odometer in a car). That means youllneed to remember where the rotor started. All of this can lead to some good OOP! :)For example, your rotor should be able to do the followingBe constructed requiring a String that defines the rotor and a single character defining the symbol that3/21/2021 Lab 5: Enigma | CS 2113 Software Engineering – Spring 2021 httpss://cs2113-s21.github.io/lab/5 3/4.Be constructed, requiring a String that defines the rotor and a single character defining the symbol thatshould be initially at the top of the Rotor. Note: in the constructor, you can call other methods, like the methodto rotate!.Rotate one click clockwise. This should involve changing the String..Return the index in the String at which a given character appears..Return the character at a given index.An example of a rotor String is #GNUAHOVBIPWCJQXDKRYELSZFMT which you are to interpret circularly, so thatthe last character loops around to the first. If you imagine that the first positition indicates the top spot on therotor, then:#GNUAHOVBIPWCJQXDKRYELSZFMT rotated one click clockwise is T#GNUAHOVBIPWCJQXDKRYELSZFMThe Enigma ClassThis we leave partly up to you. We expect your Engima to have 5 possible rotors, and when your Enigma class iscreated, it chooses which 3 to use along with their rotor starting symbols. You must hardcode the 5 possible rotorsin your class as the following Strings:.#GNUAHOVBIPWCJQXDKRYELSZFMT.#EJOTYCHMRWAFKPUZDINSXBGLQV.#BDFHJLNPRTVXZACEGIKMOQSUWY.#NWDKHGXZVRIFJBLMAOPSCYUTQE.#TGOWHLIFMCSZYRVXQABUPEJKNDYou must also have encrypt and decrypt methods for encrypting and decrypting strings. These must be compatiblewith the Comms.java file that we give you. The behavior in these methods must follow the enigma proceduredescribed Above in Our Simple Model of the Enigma.The Comms ClassNote you should not edit the Comms class, but you do need to know how it works.This is the programs main class, and it is provided for you. The program takes as input (from the command line)the three rotors and their starting characters. A correct call to the program Comms will provide all the informationneeded to setup enigma for that encryption/decryption session on the command-line, and the actual string toencrypt/decrypt should be input from standard in.,– inner rotor initially positioned so X is on top|,– middle rotor initially positioned so # is on top|| ,– outer rotor initially positioned so Y is on top|| /java Comms 4 2 3 X#Y encrypt| | || | `– outer rotor is rotor 3| `– middle rotor is rotor 2`– inner rotor is rotor 4A couple example runs Are here. You must also make your own tests and fully test your code:~/$ java Comms 1 2 3 ### encryptAAANDU3/21/2021 Lab 5: Enigma | CS 2113 Software Engineering – Spring 2021 httpss://cs2113-s21.github.io/lab/5 4/4~/$ java Comms 3 1 2 SAT encryptDO#YOUR#BEST#AND#KEEP#ON#KEEPIN#ONACAAFAEOZFWKBQKPXZOGIKXTNPEBDXWQCZ~/$ java Comms 5 2 4 EST decryptCSHIAWDFGDCOE#EZKJHRWAZDDCBCILON#PKUJEXEXSHINZTHE#NATIONAL#ANIMAL#OF#SCOTLAND#IS#THE#UNICORNSubmissionYou must submit.Enigma.java : Enigma class.Rotor.java : Rotor class.README.md : Answer questions and describe your work in this labYour Enigma.java And Rotor.java must meet the specifications above.This lab is Adopted from IC211 (spring 2019) at USNA.CS 2113 Software Engineering -Spring 2021(c) Adam J. Aviv (2021)aaviv@gwu.eduComputer ScienceThe George Washington University请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。