Question: In Java: Your Problem : You have been given list of words (call it originalList ) each of which can contain letters, digits or any

In Java:

Your Problem: You have been given list of words (call it originalList) each of which can contain letters, digits or any other characters. The encoding of these words is done as follows:

Characters are mapped as follows: (A maps to C, etc. Any character not listed here maps to itself. Thus a ? maps to ?)

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

A

B

a

b

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

y

z

c

d

e

f

g

h

i

j

k

l

m

n

o

p

q

r

s

t

u

v

w

x

y

z

a

b

0

1

2

3

4

5

6

7

8

9

2

3

4

5

6

7

8

9

0

1

Write a Java program to perform the encoding and decoding operations: Your program should accept the original list and create an encodedList where each word is an encoding of the corresponding word in the originalList. It should then create a decodedList in which each word is a decoding of the corresponding word in the encodedList. Observe that the decodedList is identical to the original list.

Write a class called EncodeDecode that has:

The following instance variables:

  • originalList This is an array of Strings, it is assigned a value by the constructor
  • encodedList Also an array of Strings. For each word of the original list, this will contain the corresponding encoded word
  • decodedList Also an array of Strings. For each word in the encodedList this will contain its decoded word, which should be the same as the corresponding word in the original list.

The following methods:

  • Constructor: The original list is passed to the constructor as a parameter oL. The constructor assigns oL to originalList. It will then call the encode method for each of the words in the originalList to populate the encodedList. It then calls the decode method for each word in the encodedList to populate the decodedList.
  • String encode (String originalWord) this maps every character in original word to 2 positions forward, with wraparound.
  • String decode (String codedWord) this maps every character in coded word to 2 positions back, with wraparound.
  • char forwardMap(char ch) supporting method, it maps the given ch to 2 positions forward (if the ch is not a letter or digit, it maps to itself)
  • char backMap(char ch) supporting method, it maps the given ch to 2 positions back (if the ch is not a letter or digit, it maps to itself)
  • getEncodedList and getDecodedList just get methods

You should create (in this order) and turn in the following documents.

  1. Test Plan: Make a table showing the input data and the expected output. Ensure that all parts of your code are properly tested.
  2. Actual Code: Write the class, instance variables and methods skeleton
  3. Flesh out the skeleton with the method bodies
  4. A class called EncodeDecodeTester that does the testing using the test plan you have created.
  5. Terminal Window showing the results.

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!