add a method for single chars
This commit is contained in:
parent
e420930ce6
commit
4163c9d70f
2 changed files with 27 additions and 2 deletions
|
@ -78,8 +78,32 @@ std::string messageToMorse(std::string &msg)
|
|||
|
||||
// Append word space if last char was not a blank
|
||||
if (msg.back() != ' ') {
|
||||
morseString.push_back('w');
|
||||
//morseString.push_back('w');
|
||||
}
|
||||
|
||||
return morseString;
|
||||
}
|
||||
|
||||
std::string charToMorse(char ch) {
|
||||
std::string morseString {};
|
||||
|
||||
if (ch == ' ') {
|
||||
morseString.push_back('w');
|
||||
return morseString;
|
||||
}
|
||||
|
||||
for (unsigned int j = 0; j < morseCode[ch].length(); j++) {
|
||||
char m = morseCode[ch][j];
|
||||
|
||||
morseString += m;
|
||||
|
||||
if (j < morseCode[ch].length() - 1) {
|
||||
morseString.push_back('i');
|
||||
}
|
||||
}
|
||||
|
||||
//morseString.push_back('c');
|
||||
|
||||
return morseString;
|
||||
|
||||
}
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
std::string messageToMorse(std::string &msg);
|
||||
std::string messageToMorse(std::string &msg);
|
||||
std::string charToMorse(char ch);
|
Loading…
Reference in a new issue