Question
Can you please verify its correct when you finish because I've posted this multiple times but I've been getting wrong answers from other people who
Can you please verify its correct when you finish because I've posted this multiple times but I've been getting wrong answers from other people who try it. (PLEASE USE C++ CODE) Thank You
In this assignment, you are going to write a program to decode messages using codes such as Morse code. This programs will use the class Code. The program will use the class to decode a message. The Morse code table is given below :
Our software will support codes that consist of symbols followed by a blank space. For example, in a message if an A appears, it will be replace by ".- ". The trailing space indicates the end of the codeword for that character. (NOTE: We will only be using the characters A-Z. Morse code words are separated by a space, so the message "cat" would be -.-. .- - x where x indicates the end of message. Note that spaces between words are denoted by 7 dots ".......". You can assume that encoded messages end with a lowercase x (which means STOP). When converting a message from text to code, a period "." should be converted to an x.)
Requirements
Your program should include the following class :
class Code
{
public:
Code(); // Default constructor - loads and uses morse code
Code(vector codewords); // constructor loading customized code
string encode(vector message); // encodes a message consisting of A-Z
string decode(vector message); // decodes a message
private:
vector codewords; // this is a codeword vector parallel to A-Z
vector alpha; // this is the vector A-Z
vector alphacode(); // function builds the vector alpha - A B C etc.
vector morsecode(); // function the vector codewords containing morse code
string encode(char x); //returns the codeword for the character x
char decode(string c); //returns the character for the codeword c.
};
The decode will input a morse code string from a file and use the classto build the decoded string, and then output the string. You can download the functions morsecode and alphacode.
International Morse Code 1. A dash is equal to three dots 2. The space between parts of the same letter is equal to one dot. 3. The space between two letters is equal to three dots 4. The space between two words is equal to seven dotsStep 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