// main.m // PolymorphicArray // Created by Robert Metcalfe on 11/10/13. Copyright (c) 2013 Robert Metcalfe. All rights reserved. #import #import @interface Cmd: NSObject -(void) showIt; -(void) execute: (Cmd *) ourcp; @end @implementation Cmd -(void) showIt { printf("%s\n", "Nothing to do"); } -(void) execute: (Cmd *) ourcp { [ourcp showIt]; } @end @interface CmdMessage: Cmd { @public char * mymsg; } -(void) showIt; @end @implementation CmdMessage -(id) initWithMessage: (char *) mymessage { self = [super init]; mymsg = mymessage; return self; } -(void) showIt { printf("%s\n", mymsg); } @end @interface CmdRepeat: Cmd { @public Cmd * thecmd; int timesToDo; } -(void) showIt; @end @implementation CmdRepeat -(id) initWithCommand: (Cmd *) mycmd times:(int) n { self = [super init]; thecmd = mycmd; timesToDo = n; return self; } -(void) showIt { for (int i=0; i