Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- string randomMood();
- class Chatbot
- {
- private:
- string name;
- string mood;
- public:
- Chatbot(string name, string mood)
- {
- setName(name);
- setMood(mood);
- }
- ~Chatbot(){
- }
- void setName(string name)
- {
- this->name = name;
- }
- string getName()
- {
- return name;
- }
- void setMood(string mood)
- {
- this->mood = mood;
- }
- string getMood()
- {
- return mood;
- }
- };
- int main()
- {
- string botname;
- cout << "What would you like to call me?" << endl;
- cin >> botname;
- Chatbot chatbot(botname, randomMood());
- cout << "My name is " << chatbot.getName() << " and right now I'm " << chatbot.getMood() << endl;
- return 0;
- }
- string randomMood()
- {
- string mood;
- srand (time(NULL));
- int moodNum = rand() % 4;
- if(moodNum == 0)
- mood = "Happy";
- else if(moodNum == 1)
- mood = "Angry";
- else if(moodNum == 2)
- mood = "Surprised";
- else
- mood = "Confused";
- return mood;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement