-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcharacters.h
42 lines (32 loc) · 954 Bytes
/
characters.h
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
#ifndef CHARACTERS_H
#define CHARACTERS_H
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ARRAY_SIZE(array) (sizeof((array))/sizeof((array[0])))
/* Set up a list of valid letters (lowercase only + space)
* Provide a method to retrieve a random letter from the list
*/
class characters
{
public:
characters();
char getElement(int element);
char getRandomLetter();
protected:
private:
char chars [27] = {' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
};
characters::characters()
{
// chars = {' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
}
char characters::getElement(int element)
{
return chars[element];
}
char characters::getRandomLetter()
{
return chars[rand() % ARRAY_SIZE(chars)];
}
#endif // CHARACTERS_H