Skip to content

Instantly share code, notes, and snippets.

@kenpower
Created February 1, 2024 09:02
Show Gist options
  • Save kenpower/cda3a3ec757fadd838810342463eba24 to your computer and use it in GitHub Desktop.
Save kenpower/cda3a3ec757fadd838810342463eba24 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <memory>
#include <string>
// English implementation
class EnglishChatbot {
public:
void hello() override {
std::cout << "Hello!" << std::endl;
}
void goodbye() override {
std::cout << "Goodbye!" << std::endl;
}
};
// French implementation
class FrenchChatbot {
public:
void hello() override {
std::cout << "Bonjour!" << std::endl;
}
void goodbye() override {
std::cout << "Au revoir!" << std::endl;
}
};
// Spanish implementation
class SpanishChatbot {
public:
void hello() override {
std::cout << "¡Hola!" << std::endl;
}
void goodbye() override {
std::cout << "¡Adiós!" << std::endl;
}
};
int main() {
SpanishChatbot spanishCB;
FrenchChatbot frenchCB;
EnglishChatbot englishCB;
std::cout << "Which language do you want? (English/French/Spanish): ";
std::cin >> language;
// whenever we want to speak....
if (language == "English") {
englishCB.hello();
englishCB.goodbye();
}
else if (language == "French") {
frenchCB.hello();
frenchCB.goodbye();
}
else if (language == "Spanish") {
spanishCB.hello();
spanishCB.goodbye();
}
else {
std::cout << "Unknown language. Using English as default." << std::endl;
englishCB.hello();
englishCB.goodbye();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment