int main() { MallardDuck duck; WildTurkey turkey; Duck *turkey_adapter=new TurkeyAdapter(&turkey); Duck *wild_turkey_class_adapter=new WildTurkeyClassAdapter(); cout<<"The Turkey says..."<<endl; turkey.Gobble(); turkey.Fly(); cout<<"\nThe Duck says..."<<endl; TestDuck(&duck); cout<<"\nThe TurkeyAdapter says..."<<endl; TestDuck(turkey_adapter); cout<<"\nThe WildTurkeyClassAdapter says..."<<endl; TestDuck(wild_turkey_class_adapter); delete turkey_adapter; delete wild_turkey_class_adapter; return 0; }
void classAdapterTestDrive() { std::cout << "\n** Class 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); TurkeyClassAdapter turkeyClassAdapter; std::cout << "\nThe TurkeyAdapter says...\n"; testDuck(turkeyClassAdapter); }
int main(int argc, char* argv[]) { MallardDuck* duck = new MallardDuck(); WildTurkey* turkey = new WildTurkey(); Duck* turkeyAdapter = new TurkeyAdapter(); std::cout << "The Turkey says..." << std::endl; turkey->gobble(); turkey->fly(); std::cout << std::endl << "The Duck says..." << std::endl; testDuck(duck); std::cout << std::endl << "The TurkeyAdapter says..." << std::endl; testDuck(turkeyAdapter); return 0; }