Question: Need help with java Translator class to implement what's in the Translator diagram. Making a morse code from english files to morse code files. Here



![Main { public static void main(String[] args) { Translator translator = new](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f91cdaa729c_88266f91cda09f41.jpg)
Need help with java Translator class to implement what's in the Translator diagram.
Making a morse code from english files to morse code files.
Here is my code so far.
---------------------------------Main.java--------------------------------
package morsecodeplayer;
public class Main {
public static void main(String[] args)
{
Translator translator = new Translator("test.mor");
translator.translate();
}
}
---------------------------------MorseCodePlayer.java--------------------------------
package morsecodeplayer;
import javax.sound.sampled.*;
public class MorseCodePlayer {
public static float SAMPLE_RATE = 8000f;
public static void dot()
throws LineUnavailableException
{
tone(1000, 75);
}
public static void dash()
throws LineUnavailableException
{
tone(500, 116);
}
public static void tone(int hz, int msecs)
throws LineUnavailableException
{
byte[] buf = new byte[1];
AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, false);
SourceDataLine sdl = AudioSystem.getSourceDataLine(af);
sdl.open(af);
sdl.start();
for (int i=0; i
double angle = i / (SAMPLE_RATE / hz) * 2.0 * Math.PI;
buf[0] = (byte)(Math.sin(angle) * 127.0 * 1);
sdl.write(buf,0,1);
}
sdl.drain();
sdl.stop();
sdl.close();
}
public static void play(String morseChar)
{
try
{
for (int i = 0; i
{
if(Character.toString(morseChar.charAt(i)).equals("."))
dot();
else
dash();
}
}
catch(LineUnavailableException ex)
{
System.out.println("Error playing the file.");
}
}
}
---------------------------------Translator.java--------------------------------
package morsecodeplayer;
public class Translator { }
Assignment The translator program adheres to the following rules: English message files will be stored as text files, one sentence per line Morse code message files will be stored as text files, one encoded character per line, where end of words are indicated by one blank line, and end of sentences are indicated by two blank lines. English message files will contain file extension eng, and Morse code files with have file extension mor The additional assumption for this project is that: Messages will contain only lowercase characters, periods, commas, question marks, dashes, and apostrophes. Morse Code Translator for the main program is given on t he next page. Note, read the The UML design diagram following description carefully to be sure you understand what is being shown. Translator Translator(inputFile: string) void nputBuffer Ou uffer utBufferinputFile: string) OfBuffer): boolean Buffer(outputFle: string) etReader): Scanner Writer): PrintWriter void : void ToWhite: sring):void isEndOrWord) :boolean void tBuffer tBuffer Eng lishlnputBuffer oken: string MorselnputBuffer string -EnglishOutputBufferOutp File : string) string) int ToWrite: string): void ToWrite: string) void void void ishinputBuffer(inputFile: string)EnglishinputBufer(inputFile: string) Char(): MsgChar ):bodlean ): boolear Powered By Visual Paradgm Community Edion
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
