Docsity

CIS 3020, Fall 2002: String Manipulation & Recursion with Cipher Class, Assignments of Computer Science

Toggle sidebar
bg1
CIS 3020, Fall 2002
Programming Assignment 6
Group Project
Worth: 60 points
Due by 11:00 p.m., November 25, 2002
Objective:
To learn and understand string manipulation and reinforce recursion.
Description:
In this assignment, you will write a program that translates a character string into
another character string using a cipher code. Cipher codes are one of the earliest
methods used in an attempt to hide information from foes who might intercept the
message during transmission. In all cipher systems we assume that our message has
been intercepted. Our goal is to make it very hard, if not impossible, for them to decrypt
the message.
One of the simplest substitutions is Caesar’s cipher:
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG
....ABCDEFGHIJKLMNOPQRSTUVWXYZ
To encode a message, a letter in the original message is located in the top row. The
corresponding letter in the lower alphabet replaces that letter in the new string. So the
message ā€œgatorā€ will be encoded to ā€œcwpknā€. To decode a message, a character in the
message is located in the bottom string and the character above it is its replacement.
The encoded message ā€œdkqoa ywpā€ is decoded to the message ā€œhouse catā€. The flaw
with this approach is that there are only 26 ways that messages can be encoded.
A more sophisticated scheme randomly distributes the characters in the lower string:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
IPHBOSFCQZJNTWGLMYRXDKEUVA
Now the recipient of your message has to know the substitution alphabet for them to be
able to decode your message. Using this approach there are a huge numbers of
possible substitutions (actually 403,291,461,126,605,635,584,000,000 for an alphabet
of 26 letters). While this is still a fairly easy cipher code to break, your assignment is to
develop a program that uses this approach.
We will refer to the top string used for encoding as encode, the lowers string as key,
and the string to be encoded as message.
Problem statement:
Create the Cipher class that supports at least the following instance behavior:
encipher (String encode, String key, String message)
This method (by itself or though the use of helper methods) should locate
each character from message in the string encode then replace that
character with the corresponding character from key. You are strongly
pf3

Partial preview of the text

Download CIS 3020, Fall 2002: String Manipulation & Recursion with Cipher Class and more Assignments Computer Science in PDF only on Docsity!

CIS 3020, Fall 2002 Programming Assignment 6 Group Project

Worth: 60 points Due by 11:00 p.m., November 25, 2002

Objective: To learn and understand string manipulation and reinforce recursion.

Description: In this assignment, you will write a program that translates a character string into another character string using a cipher code. Cipher codes are one of the earliest methods used in an attempt to hide information from foes who might intercept the message during transmission. In all cipher systems we assume that our message has been intercepted. Our goal is to make it very hard, if not impossible, for them to decrypt the message.

One of the simplest substitutions is Caesar’s cipher:

ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG ....ABCDEFGHIJKLMNOPQRSTUVWXYZ

To encode a message, a letter in the original message is located in the top row. The corresponding letter in the lower alphabet replaces that letter in the new string. So the message ā€œgatorā€ will be encoded to ā€œcwpknā€. To decode a message, a character in the message is located in the bottom string and the character above it is its replacement. The encoded message ā€œdkqoa ywpā€ is decoded to the message ā€œhouse catā€. The flaw with this approach is that there are only 26 ways that messages can be encoded.

A more sophisticated scheme randomly distributes the characters in the lower string:

ABCDEFGHIJKLMNOPQRSTUVWXYZ IPHBOSFCQZJNTWGLMYRXDKEUVA

Now the recipient of your message has to know the substitution alphabet for them to be able to decode your message. Using this approach there are a huge numbers of possible substitutions (actually 403,291,461,126,605,635,584,000,000 for an alphabet of 26 letters). While this is still a fairly easy cipher code to break, your assignment is to develop a program that uses this approach.

We will refer to the top string used for encoding as encode , the lowers string as key , and the string to be encoded as message.

Problem statement: Create the Cipher class that supports at least the following instance behavior:

encipher (String encode, String key, String message ) This method (by itself or though the use of helper methods) should locate each character from message in the string encode then replace that character with the corresponding character from key. You are strongly

encouraged to use helper methods and must use recursion in your solution.

Driver Program:

Write the CipherDemo class demonstrating the encipher method. The following strings should be used:

Encode: 1234567890 .,()?!’-:;ABCDEFGHIJKLMNOPQRSTUVWXYZ

Key: Z G1HODIWQX50CSYT,(:6M-J8)?U2;7E’AF!VK3L4NBP9R.

Encode each of the following strings:

ā€˜what’s it going to be then, eh?’ there was me, that is alex, and my three droogs, that is pete, georgie, and dim, dim being really dim, and we sat in the korova milkbar making up our rassoodocks what to do with the evening, a flip dark chill winter bastard though dry. Gavin dopedrifted through the sensemadness of karnival like a molecule enslaved in one of the savage’s amplifiers, vibrating with the chords of the bass guitar, beaten from side to side by the hammering drum, darting with the stringplay of the lead, in unrelenting, irrelevant motion…. throb, boom-boom, tinkle, twinkle, plink…

Demonstrate that your program works by using encipher to decode each message to

obtain the original string. If our string to encode was ā€œthe catā€, the program should print:

Original message: the cat

Encoded message: 42)xjm

Decoding of message: the cat

Deliverables:

Each group is required to submit one copy of the following material. In solving this problem, each group should designate one member as a recorder. It is the responsibility of the recorder to submit the group’s solution before the required due date and time. The recorder is also responsible for bringing all paper materials that are to be submitted to the final review.

You are required to submit electronically:

  1. The Java source code for the classes used to solve this problem.

See directions below on how to submit this electronically.

You are required to turn in on paper:

  1. An analysis and design of each of the methods developed.
  2. A UML specification of all classes and methods written for PA6.

Submission Instructions: