void objectAdapterTestDrive() {
    std::cout << "\n** Object Adapter Pattern Test Drive **\n\n";

    WildTurkey turkey;
    std::cout << "The Turkey says...\n";
    turkey.gobble();
    turkey.fly();

    MallardDuck duck;
    std::cout << "\nThe Duck says...\n";
    testDuck(duck);

    TurkeyAdapter turkeyAdapter(turkey);
    std::cout << "\nThe TurkeyAdapter says...\n";
    testDuck(turkeyAdapter);
}
//! Client
int main() {
	std::auto_ptr<MallardDuck> duck (new MallardDuck());
	
	std::auto_ptr<WildTurkey> turkey (new WildTurkey());
	std::auto_ptr<Duck> turkeyAdapter (new TurkeyAdapter(turkey.get()));
	
	std::cout << "The Turkey says..." << std::endl;
	turkey->gobble();
	turkey->fly();
	
	std::cout << "The Duck says..." << std::endl;
	testDuck(duck.get());
	
	std::cout << "The Turkey Adapter says..." << std::endl;
	testDuck(turkeyAdapter.get());

	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char* argv[])
{
	shared_ptr<MallardDuck> duck(new MallardDuck());

	shared_ptr<WildTurkey> turkey(new WildTurkey());
	shared_ptr<Duck> turkeyAdapter(new TurkeyAdapter(turkey));

	cout << "The Turkey says..." << endl;
	turkey->gobble();
	turkey->fly();

	cout << endl << "The Duck says..." << endl;
	testDuck(duck);
	
	cout << endl << "The TurkeyAdapter says..." << endl;
	testDuck(turkeyAdapter);

	return 0;
}