Advertisement
irmantas_radavicius

Untitled

Mar 23rd, 2022
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3.  
  4. using namespace std;
  5.  
  6. string randomMood();
  7.  
  8. class Chatbot
  9. {
  10.     private:
  11.     string name;
  12.     string mood;
  13.  
  14.     public:
  15.     Chatbot(string name, string mood)
  16.     {
  17.         setName(name);
  18.         setMood(mood);
  19.     }
  20.     ~Chatbot(){
  21.     }
  22.  
  23.     void setName(string name)
  24.     {
  25.         this->name = name;
  26.     }
  27.     string getName()
  28.     {
  29.         return name;
  30.     }
  31.  
  32.     void setMood(string mood)
  33.     {
  34.         this->mood = mood;
  35.     }
  36.     string getMood()
  37.     {
  38.         return mood;
  39.     }
  40. };
  41.  
  42. int main()
  43. {
  44.     string botname;
  45.     cout << "What would you like to call me?" << endl;
  46.     cin >> botname;
  47.     Chatbot chatbot(botname, randomMood());
  48.     cout << "My name is " << chatbot.getName() << " and right now I'm " << chatbot.getMood() << endl;
  49.     return 0;
  50. }
  51.  
  52. string randomMood()
  53. {
  54.     string mood;
  55.     srand (time(NULL));
  56.     int moodNum = rand() % 4;
  57.     if(moodNum == 0)
  58.         mood = "Happy";
  59.     else if(moodNum == 1)
  60.         mood = "Angry";
  61.     else if(moodNum == 2)
  62.         mood = "Surprised";
  63.     else
  64.         mood = "Confused";
  65.     return mood;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement