#include
#include
using namespace std;
class Toy {
public:
virtual void talk() const=0;
};
class Dog: public Toy {
// Write your code here
public:
void talk()
{
cout<<"Wow"<<endl;
}
};
class Cat: public Toy {
// Write your code here
public:
void talk()
{
cout<<"Meow"<<endl;
}
};
class ToyFactory {
public:
/**
* @param type a string
* @return Get object of the type
/
Toy getToy(string& type) {
// Write your code here
if(type=="Dog")
{
Dog d;
return d;
}
if(type=="Cat")
{
Cat *c;
return c;
}
}
};
int main()
{
string type;
type="Dog";
ToyFactory tf = new ToyFactory();
Toy* toy = tf->getToy(type);
toy->talk();
return 0;
}