首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
CS 2113程序讲解、辅导Java编程、讲解Java程序 讲解留学生Processing|辅导R语言程序
项目预算:
开发周期:
发布时间:
要求地区:
Lab 5: Enigma | CS 2113 Software Engineering
Preliminaries
Github Link
Accept this assignment here: https://classroom.github.com/a/Nn5yicQDevelopment
Environment
This lab can be developed locally on your machine using any java installation or on replit.
Running/Compile your program
You should compile your program using javac and run it with java . The specific command line arguments are
provided below.
Testing your lab
We 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 a
breakthrough in cryptography, and was essentially an extremely advanced substitution cipher. The Enigma machine
is also famous for not just being a very advanced cipher, but also because it was broken by none other than Alan
Turning, whom many consider the founder of computer science.
In this lab, we will model a simplified version of the Enigma machine. If youʼre 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 of
this lab.)
What you need to know for this lab
What you need to know for this lab: Enigma machines used interchangeable rotors that could be placed in different
orientations to obtain different substitution patterns. More significantly, the rotors rotated after each character was
encoded, changing the substitution pattern and making the code very difficult to break. The behavior of the
rotating rotors can be modeled, in a simplified form, by a device consisting of labeled, concentric rings. For
example, 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 the
character 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 inner
rotor clockwise one step. Whenever the inner rotor returns to its original orientation, the middle rotor turns once in
lock-step, just like the odometer in a car.
CS2113SoftwareEngineering-Spring2021
3/21/2021 Lab 5: Enigma | CS 2113 Software Engineering - Spring 2021
https://cs2113-s21.github.io/lab/5 2/4
For example, in this configuration the character ‘Aʼ would be encrypted as ‘Nʼ, since ‘Aʼ on the inner rotor is aligned
with ‘Hʼ on the outer rotor, and ‘Hʼ on the middle rotor is aligned with ‘Nʼ on the outer rotor. After performing this
encryption, 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 outer
rotor, note the character aligned with it on the middle rotor, find that character on the outer rotor, then output the
character aligned with it on the inner rotor. Donʼt forget to rotate the rotors after each letter is decrypted.
Task Requirements
The Task
You will define a class Rotor to simulate the workings of a single rotor, and the class Enigma to simulate the
workings of an Enigma machine using Rotor instances. You will be provided a class Comms (with a main
method) as part of the initial material. You should read that file to see how Enigma instances are suppose to be
used.
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, information
hiding, and encapsulation.
The Rotor Class
The 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 the
characters in a String of length 27 ( # indicating space) – index 0 is the top most character. Note that
Rotors rotate! And after a full rotation, the next outer rotate rotates (like a odometer in a car). That means youʼll
need 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 following
Be constructed requiring a String that defines the rotor and a single character defining the symbol that
3/21/2021 Lab 5: Enigma | CS 2113 Software Engineering - Spring 2021
https://cs2113-s21.github.io/lab/5 3/4
.
Be constructed, requiring a String that defines the rotor and a single character defining the symbol that
should be initially at the top of the rotor. Note: in the constructor, you can call other methods, like the method
to 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 that
the last character loops around to the first. If you imagine that the first positition indicates the top spot on the
rotor, then:
#GNUAHOVBIPWCJQXDKRYELSZFMT rotated one click clockwise is T#GNUAHOVBIPWCJQXDKRYELSZFM
The Enigma Class
This we leave partly up to you. We expect your Engima to have 5 possible rotors, and when your Enigma class is
created, it chooses which 3 to use along with their rotor starting symbols. You must hardcode the 5 possible rotors
in your class as the following Strings:
.
#GNUAHOVBIPWCJQXDKRYELSZFMT
.
#EJOTYCHMRWAFKPUZDINSXBGLQV
.
#BDFHJLNPRTVXZACEGIKMOQSUWY
.
#NWDKHGXZVRIFJBLMAOPSCYUTQE
.
#TGOWHLIFMCSZYRVXQABUPEJKND
You must also have encrypt and decrypt methods for encrypting and decrypting strings. These must be compatible
with the Comms.java file that we give you. The behavior in these methods must follow the enigma procedure
described above in “Our Simple Model of the Enigma”.
The Comms Class
Note you should not edit the Comms class, but you do need to know how it works.
This is the programʼs 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 information
needed to setup enigma for that encryption/decryption session on the command-line, and the actual string to
encrypt/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 4
A couple example runs are here. You must also make your own tests and fully test your code:
~/$ java Comms 1 2 3 "###" encrypt
AAA
NDU
3/21/2021 Lab 5: Enigma | CS 2113 Software Engineering - Spring 2021
https://cs2113-s21.github.io/lab/5 4/4
~/$ java Comms 3 1 2 "SAT" encrypt
DO#YOUR#BEST#AND#KEEP#ON#KEEPIN#ON
ACAAFAEOZFWKBQKPXZOGIKXTNPEBDXWQCZ
~/$ java Comms 5 2 4 "EST" decrypt
CSHIAWDFGDCOE#EZKJHRWAZDDCBCILON#PKUJEXEXSHINZ
THE#NATIONAL#ANIMAL#OF#SCOTLAND#IS#THE#UNICORN
Submission
You must submit
.
Enigma.java : Enigma class
.
Rotor.java : Rotor class
.
README.md : Answer questions and describe your work in this lab
Your 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.edu
Computer Science
The George Washington University
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!