1 Replies - 5918 Views - Last Post: 07 November 2010 - 03:46 AM Rate Topic: -----

#1 buzzdogear777   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-October 10

Morse Code Translator

Posted 06 November 2010 - 08:18 PM

Hi all,
I have to do a Morse Code Translator for an assignment and I can't figure out how this works. This is the assignment

Create a class called MorseCode that has at least the following two methods: (1) a method with signature toMorseCode(char) that accepts a single capital letter from the English alphabet and returns an array of 4 characters representing the Morse code equivalent of that letter, and (2) a method with signature fromMorseCode(char[4]) that accepts an array of four Morse code characters (either a dot, a dash, or space) and returns the English letter equivalent. The MorseCode class will have two static variables. The first, of type char[], will store the 26 letters of the alphabet. The second, of type char[][], will store the Morse code for each of the 26 letters of the alphabet.

Create a driver class called TestMorseCode. At a minimum:

When the program runs, it should first print its name
The program should next ask the user first whether the original input will be in English or in Morse code
Based on the user's answer, the program will ask the user to enter either a phrase in English, or the Morse code for a phrase
If the user is entering an English phrase, a carriage return will indicate the end of the phrase. If the user is entering Morse code, any character other than . (dot), - (dash), or space will indicate the end of the phrase
The program will then print the result after conversion
Your source code must conform to good programming style, with all comments in Javadoc format.

and this is what I have so far

public class MorseCode {

	public char[] alphabet;
	public char[][] morseCode;
        public char[] getAlphabet() {
		return alphabet;
	public void setAlphabet(char[] alphabet) {
		this.alphabet = alphabet;
	public char[][] getMorseCode() {
		return morseCode;
	public void setMorseCode(char[][] morseCode) {
		this.morseCode = morseCode;
	public void toMorseCode(char input){
	public void fromMorseCode(char[4]){
	public static void main(String[] args) {



I literally have no idea where to begin. Can someone point me in the right direction?


Is This A Good Question/Topic? 0
  • +

Replies To: Morse Code Translator

#2 GregBrannon   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2250
  • View blog
  • Posts: 5,340
  • Joined: 10-September 10

Re: Morse Code Translator

Posted 07 November 2010 - 03:46 AM

You've gotten lots of views but no responses. I suspect that this is because the code you've posted doesn't qualify as 'making an effort.'

If you're still out there, I suggest a good place to start would be to construct the two arrays the problem statement suggests and then think about what you might do with them with the required 2 methods to reach an answer.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1