Question: Morse Code Lab 1 ) Implement an interface Converter 2 ) Read in a file that express the code as pairs char to encode The
Morse Code Lab
Implement an interface Converter
Read in a file that express the code as pairs
char to encode
The combination of dashes and dots the represent it
Read in file to
Encode
Decode
Parameters:
Use two hashmaps
To store the strings for the letter and Morse code, use two hashmaps:
One to go from letter to morse
One to go from morse to letters
read the codes in from the MORSECODETABLE file
You should pass the filename into the object via the constructor see main method
Given Code:
import java.ioBufferedReader;
import java.ioFileNotFoundException;
import java.ioFileReader;
import java.ioIOException;
public class Main
public static void mainString args
MorseConverter mc new MorseConverterMorseCodeTabletxt;
String workingDir System.getPropertyuserdir";
mcprintKeyValuePairs;
String fileName "Quotetxt;
String copyfileName "QuoteCopy.txt;
String saveFileName "QuoteMorse.txt;
StringBuilder sb new StringBuilder;
try BufferedReader br new BufferedReadernew FileReaderworkingDir fileName
String line ;
while line brreadLine null
sbappendline;
catch FileNotFoundException e
System.out.printworkingDir fileName File Not found";
catch IOException e
eprintStackTrace;
mcencodeSaveToFilesbtoString workingDir saveFileName;
String encodeCopy mcencodesbtoString;
mcdecodeSaveToFileencodeCopy workingDir copyfileName;
Given Interface:
public interface Converter
public void printKeyValuePairs;
public String encodeString textToEncode;
public String decodeString textToDecode;
public boolean decodeSaveToFileString decode, String filename ;
public boolean encodeSaveToFileString encode, String filename ;
Given MorseCodeTable.txt
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
:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
