forked from ddtruong50/cpsc254-git_lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagic8Ball.h
More file actions
49 lines (37 loc) · 959 Bytes
/
Magic8Ball.h
File metadata and controls
49 lines (37 loc) · 959 Bytes
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
49
#ifndef MAGIC8BALL_H
#define MAGIC8BALL_H
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
void magic8ball()
{
const int ARRAY_LENGTH = 6;
string eightBall[ARRAY_LENGTH];
bool prgExit = false;
srand(time(0));
string userInput;
eightBall[0] = "No";
eightBall[1] = "Yes";
eightBall[2] = "Perhaps...";
eightBall[3] = "Most definitely yes!";
eightBall[4] = "Almost positively not";
eightBall[5] = "I think so...";
cout << "Welcome to the Magic 8-ball!\n";
cout << "Ask me a yes or no question to play, or type 'exit' to quit\n";
while (!prgExit)
{
cout << "\nAsk me a question and I will tell the future!\n";
getline(cin, userInput);
if (userInput.compare("exit") == 0)
prgExit = true;
if (userInput.compare("") != 0 && userInput.compare("exit") != 0)
{
cout << eightBall[rand() % ARRAY_LENGTH] << endl;
userInput = "";
}
}
cout << "Thanks for playing!\n";
}
#endif