Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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, getDecodedList just get methods

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

=+b. Campbell Soup: http://www.campbellsoup.com

Answered: 1 week ago

Question

What are the attributes of a technical decision?

Answered: 1 week ago

Question

How do the two components of this theory work together?

Answered: 1 week ago

Question

4. Explain how to price managerial and professional jobs.pg 87

Answered: 1 week ago