Magic Sarcastic 8-ball!

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
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <fac.h>
using namespace std;

int main()
{
    srand( (unsigned)time(0) );
    int a;
    string whatever;
    do{
    a = (rand()%12);
    getline(cin, whatever);
    if(whatever == "What is the answer to life, the universe, and everything?"){
    cout << "42.";
    continue;}
    switch(a)
    {
        case 0:
            cout << "Of course! ";
            delay(1);
            cout << "NOT! ";
            break;
        case 1:
            cout << "Psssht, yeah right. ";
            break;
        case 2:
            cout << ".....No. Just....no. ";
            break;
        case 3:
            cout << "Ummmmmmm...not a chance. ";
            break;
        case 4:
            cout << "Reply hazy. Try again when you get a life. ";
            break;
        case 5:
            cout << "You lucky dog. Your dreams might come true. MIGHT. ";
            break;
        case 6:
            cout << "Maybe.... ";
            break;
        case 7:
            cout << "\"Derhats...\"--Robert Barone (Everybody Loves Raymond) ";
            break;
        case 8:
            cout << "*grumble* YES.... ";
            break;
        case 9:
            cout << "Unfortunately... ";
            delay(1);
            cout << "yes. ";
            break;
        case 10:
            cout << "Yes, much to some virtual 8-ball's dismay. ";
            break;
        case 11:
            cout << "Your dreams shall come true... Darn. "; 
            break;}
    }while(true);}

Enjoy. ;)

EDIT: Because people don't know where to find fac.h, I'll post a link.
http://www.cplusplus.com/forum/lounge/2815/
Last edited on
I tried compiling on Dev C++ and Visual C++ but didn't work. They couldn't find the fac.h header file.
You don't need it. Just remove it. And that delay() on line 20.

You do need to add <string> and <cstdlib> though.

(QWERTYman wrote fac.h himself http://www.cplusplus.com/forum/lounge/2815/ . If you want to keep that 1s delay in there you'll need a function to do it. I recommend one of the following:
http://www.gidforums.com/t-10292.html#2
http://msdn.microsoft.com/en-us/library/ms686298(VS.85).aspx
You could also just use his fac.h file. Change it to #include "fac.h".)
I added something. 20 Internet points if you get the reference to a reference.
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <fac.h>
using namespace std;

int main()
{
    srand( (unsigned)time(0) );
    int a;
    string whatever;
    do{
    a = (rand()%12);
    getline(cin, whatever);
    if(whatever == "What is the answer to life, the universe, and everything?"){
    cout << "42."; continue;}
    if(whatever == "Is it a trap?"){
cout << "......................................\n\n"<<
"...............................(IT'S A TRAP!)...\n\n"<<
"..................._,,,--~~~~~~~~--,_....V....\n\n"<<
"................,-‘::::::::::::::::::º‘-,............\n\n"<<
"..............,-‘:::::::::::::::::::::::o:‘-,..........\n\n"<<
"............,-‘:::::::::::::::::::::::::::::O‘-,.........\n\n"<<
"..........,-‘::::::::::::::::,:::º:::::::::::::’;........\n\n"<<
"........,-‘//::::::::::::::::::-,;;;;;;;;;;;;;;;;\\........\n\n"<< 
"....../,-‘,’:::::::::::::::::‘-,;;;;;;;;;;;;;;;;;;;|.......\n\n"<<
"...../,’,-‘::::::::::::::: :_,-~~,_’-,;;;;;;;;;;;;;|.......\n\n"<<
"..._/:,’:/::::::::::::_,-‘/:,-‘;’-‘’’’’~-,;;;;;;,’........\n\n"<<
"...,-‘/::::::,-‘’’:::,--‘’:||/,-‘-‘--‘’’__,’’’\\;;;,-‘........\n\n"<<
"...\\:/,,:::_,-‘--,,_::\\:\\||//,-‘-‘x###::\\\\;;/..........\n\n"<<
"....\\//---‘’’’:\\#\\::\\::\\:\\\\||:(O##º:://-‘’...........\n\n"<<
"..../,’____::\\‘-#\\:\\,::\\:\\\\\\:‘-,___,-‘,-`-,,...........\n\n"<<
"....‘)::::’’’’--,,--,,,,,,¯\\\\::::--,,_’’-,,’’’¯:’- :’-,.........\n\n"<<
".....)::::::,,:‘’’’~~~~’\\:::::::’’’’’¯::,-‘:,/\\.........\n\n"<<
".....\\,//|\\\\||://:::::::,’-,::::::::::,--‘’:,-‘\\\\........\n\n"<<
".....\\\\’|\\\\\\|/‘//:::_--,,:,|)’;:::::::,-‘’:,-‘:::\\\\,.......\n\n"<<
"..../¯:|\\|\\:|/\\::::----,:\\/:|/::::,-‘’::,-‘::::::‘’-,,_....\n\n"<<
"....|:::/‘’-(,::::::‘’’’’~,,,,,’’::,-‘’::,-‘:::::::::,-‘’’\\\\....\n\n"<<
".,-‘:::|::‘’):::¯’’’’~-,::,--‘’’::,-‘’:::::::::,-‘:¯’’’’’-,_.\n\n"<<
"./:::::`-,::|::::::_,,-‘’’’¯:,--‘’:::::::::::/:::::::’’-,\n\n"<<
"/:::::-,:¯’’’’’’’’’’’¯::_,,-~’’::::::::::::::|:::::::::\n\n"<<
"::::::::¯’’~~~~~~’’’::::::::::::::::::|:::::::::\n\n";continue;}
    switch(a)
    {
        case 0:
            cout << "Of course! ";
            delay(1);
            cout << "NOT! ";
            break;
        case 1:
            cout << "Psssht, yeah right. ";
            break;
        case 2:
            cout << ".....No. Just....no. ";
            break;
        case 3:
            cout << "Ummmmmmm...not a chance. ";
            break;
        case 4:
            cout << "Reply hazy. Try again when you get a life. ";
            break;
        case 5:
            cout << "You lucky dog. Your dreams might come true. MIGHT. ";
            break;
        case 6:
            cout << "Maybe.... ";
            break;
        case 7:
            cout << "\"Derhats...\"--Robert Barone (Everybody Loves Raymond) ";
            break;
        case 8:
            cout << "*grumble* YES.... ";
            break;
        case 9:
            cout << "Unfortunately... ";
            delay(1);
            cout << "yes. ";
            break;
        case 10:
            cout << "Yes, much to some virtual 8-ball's dismay. ";
            break;
        case 11:
            cout << "Your dreams shall come true... Darn. "; 
            break;}
    }while(true);}
Topic archived. No new replies allowed.