Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started