forked from jameskbride/cmake-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorld.cpp
33 lines (26 loc) · 849 Bytes
/
HelloWorld.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
#include <Speaker.h>
#include <cstdlib> // for rand() and srand()
#include <ctime> // for time()
using namespace std;
using namespace Hello;
int main(int argc, char *argv[]) {
// Initialize random seed
srand(static_cast<unsigned int>(time(0)));
// Array of random greetings
const char* greetings[] = {
"Hello!",
"Hi there!",
"Greetings!",
"Salutations!",
"Howdy!"
};
// Select a random greeting
int randomIndex = rand() % (sizeof(greetings) / sizeof(greetings[0]));
const char* randomGreeting = greetings[randomIndex];
Speaker* speaker = new Speaker();
// Use the random greeting in some way
cout << randomGreeting << endl; // Print the random greeting
speaker->sayHello(); // Call sayHello method
delete speaker; // Clean up
return 0;
}