-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelper.cpp
48 lines (42 loc) · 916 Bytes
/
Helper.cpp
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
43
44
45
46
47
48
#include "Helper.h"
#include <iostream>
#include <stdio.h>
using namespace std;
Helper::Helper(){};
Helper::~Helper(){};
// Checking if a string is composed entirely of digits
bool Helper::isInt (string s) {
for (int i = 0; i < s.length(); i++) {
if (!isdigit(s.at(i))) // Checking if char is a digit
return false;
}
return true;
}
// String.tolower
string Helper::toLowerCase(string s) {
for (int i = 0; i < s.length(); i++) {
s[i] = tolower(s.at(i));
}
return s;
}
// Function to change "one" to "1", etc if applicable
string Helper::alphaToDigit(string s) {
if (s == "twp")
return "2";
else if (s == "three")
return "3";
else if (s == "four")
return "4";
else if (s == "five")
return "5";
else if (s == "six")
return "6";
else if (s == "seven")
return "7";
else if (s == "eight")
return "8";
else if (s == "nine")
return "9";
else
return s;
}