Question: Provide and fix the inputBinaryCode class so it properly translates from binary to english or morse code. the program code provided is designed to convert
Provide and fix the inputBinaryCode class so it properly translates from binary to english or morse code.
the program code provided is designed to convert between english, morse code and binary ascii code. the main program and all classes except the inputbinarycodemessage and outputbinarycodemessage classes are implemented. therefore, you must implement these two unimplemented classes and do program testing. following is a class diagram for the program, given in a uml class diagram. note: message files may contain only uppercase characters, spaces and a period. java
Here is the current codes I have, currently there seems to be a problem for the binary input class: Binary Code data table: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
MorseCode data table: 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
Exception Classes:By James Edward Bramble, Section
package Exceptions;
public class InvalidBinaryCodeFoundException extends RuntimeException
public InvalidBinaryCodeFoundException
super;
By James Edward Bramble, Section
package Exceptions;
public class InvalidCharFoundException extends RuntimeException
public InvalidCharFoundException
super;
public InvalidCharFoundExceptionString str
superstr;
By James Edward Bramble, Section
package Exceptions;
public class InvalidMessageTypeException extends RuntimeException
public InvalidMessageTypeException
super;
public InvalidMessageTypeExceptionString str
superstr;
Input Message Classes:
By James Edward Bramble, Section
package InputMessageTypes;
import java.ioBufferedReader;
import java.ioFileReader;
import java.ioFileNotFoundException;
import java.ioIOException;
Import Project Classes
import Exceptions.InvalidCharFoundException;
public class InputBinaryCodeMessage extends InputMessage
Instance Variables
private String lineread null;
private String linebuffer;
private int currentcharindex;
private String lastbinaryletterread ;
private String binarycode new String;
private String binarycodefilename DataBinaryCodeTable.txt;
Constructor
public InputBinaryCodeMessageBufferedReader input throws
FileNotFoundException, IOException
superinput;
populateBinaryCodebinarycodefilename;
CharacterOrdinal Conversion Methods
public int getOrdinalString binarystr
Returns ordinal value position of chr in the encoding.
int ordinalvalue ;
for int i ; i binarycode.length; i
if binarycodeiequalsbinarystr
ordinalvalue i;
return ordinalvalue;
Input Reading Methods
public String readLetter throws IOException, InvalidCharFoundException
Reads and returns next Binaryencoded letter from input file
or null if endoffile found.
Also sets previousbinaryletter to current value of
binaryletter, and sets binaryletter to new letter read.
Check for endoffile
if lineread null
lineread getNextLine;
if lineread null
return null;
linebuffer lineread.trim;
currentcharindex ;
Check if we need to read a new line
if currentcharindex linebuffer.length
lineread getNextLine;
if lineread null
return null;
linebuffer lineread;
currentcharindex ;
Check for invalid Binary code found
if currentcharindex linebuffer.length
throw new InvalidCharFoundExceptionIncomplete binary data";
String binaryletter linebuffer.substringcurrentcharindex, currentcharindex ;
currentcharindex currentcharindex ;
Validate that the binary represent
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
