home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / alt / hackers / 1346 < prev    next >
Encoding:
Text File  |  1992-09-01  |  2.0 KB  |  92 lines

  1. Xref: sparky alt.hackers:1346 talk.bizarre:28422
  2. Newsgroups: alt.hackers,talk.bizarre
  3. Path: sparky!uunet!think.com!sdd.hp.com!elroy.jpl.nasa.gov!ames!sgi!wdl1!bard
  4. From: bard@cutter.ssd.loral.com (J H Woodyatt)
  5. Subject: Your very own Magic 8 Ball simulator
  6. Message-ID: <1992Sep1.232614.15386@wdl.loral.com>
  7. Sender: news@wdl.loral.com
  8. Reply-To: bard@cutter.ssd.loral.com
  9. Organization: Abiogenesis 4 Less
  10. Date: Tue, 1 Sep 1992 23:26:14 GMT
  11. Approved: dante@inferno.com
  12. Lines: 78
  13.  
  14. //
  15. // magic8  -- A magic 8 ball simulator
  16. //
  17. // Author:  James Woodyatt <bard@cutter.ssd.loral.com>
  18. //
  19. //
  20.  
  21. #include <iostream.h>
  22. #include <stdlib.h> 
  23. #include <time.h>
  24. #include <unistd.h>
  25.  
  26. class EightBall
  27. {
  28.     const int N_Array = 20;
  29.     static const char*  array[N_Array];
  30.     const char*  string;
  31.  
  32.   public:
  33.     void select()  { string = array[rand() % N_Array]; }
  34.     EightBall()    { select(); }
  35.     
  36.     operator const char*() const  { return string; }
  37. };
  38.  
  39. const char* EightBall::array[N_Array] =
  40. {
  41.     "YES.",
  42.     "You may rely on it.",
  43.     "It is decidedly so.",
  44.     "Yes, definitely.",
  45.     "Without a doubt.",
  46.     "It is certain.",
  47.  
  48.     "Most likely.",
  49.     "Outlook good.",
  50.     "Signs point to `yes.'",
  51.     "As I see it, yes.",
  52.  
  53.     "Reply hazy, try again.",
  54.     "Concetrate and ask again.",
  55.     "Ask again later.",
  56.     "Better not tell you now.",
  57.     "Cannot predict now.",
  58.  
  59.     "My sources say, `No.'",
  60.     "Very doubtful.",
  61.     "Don't count on it.",
  62.     "Outlook not so good.",
  63.  
  64.     "My reply is: No.",
  65. };
  66.  
  67.  
  68. int main(int, const char*[])
  69. {
  70.     srand(time(0) + getpid());
  71.     
  72.     EightBall eightball;
  73.  
  74.     cout << eightball << endl;
  75.     return 0;
  76. }
  77.  
  78. //--- End of program [ magic8.C ]
  79.  
  80.  
  81. Maybe when I'm really bored, I'll make one with an X interface.
  82.  
  83. Please note newsgroups line.
  84.  
  85. -- 
  86. J H Woodyatt (a.k.a. Dr. Strychnine)
  87. Space Systems/Loral
  88.  
  89. "there's a lot going on that you miss. nothing soft about THESE
  90. machines. mean, timeless, mean, purposeful, crammed with meaning."
  91.                                                   -- Andrew Palfreyman
  92.