-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranslator.cpp
More file actions
42 lines (38 loc) · 1.24 KB
/
Translator.cpp
File metadata and controls
42 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Translator.h"
Translator::Translator(){
mo = new Model();
cout << "Translator contructor" << endl;
}
Translator::~Translator(){
delete mo;
cout << "Translator destructor" << endl;
}
string Translator::translateEnglishWord(string word){
string newWord;
for(int i = 0; i < word.size(); ++i){
char letter = word[i];
if(!(word[i] == 'a' || word[i] == 'e' || word[i] == 'i' || word[i] == 'o' || word[i] == 'u')){
newWord += mo->translateSingleConsonant(word[i]);
}
else{
newWord += mo->translateSingleVowel(word[i]); //this may need to be casted to string or something
}
}
return newWord;
}
string Translator::translateEnglishSentence(string sentence){
string newSentence;
for(int i = 0; i < sentence.size(); ++i){
char letter = sentence[i];
if(sentence[i] == ' '){
newSentence += ' ';
}
else if(!(sentence[i] == 'a' || sentence[i] == 'e' || sentence[i] == 'i' || sentence[i] == 'o' || sentence[i] == 'u')){
newSentence += mo->translateSingleConsonant(sentence[i]);
}
else{
newSentence += mo->translateSingleVowel(sentence[i]);
}
}
return newSentence;
}