
#import <stdlib.h>

#import <objc/Object.h>
#import "Fib.h"

int main( int argc, char **argv )
{
   id f = [Fib new];
   int n = 5;
   int answer;
    
   if ( argc == 2 ) 
   {
      n = atoi( argv[1] );
   }
   else if ( argc == 3 ) 
   {
      n = atoi( argv[2] );
      if ( argv[1][0] == 'r' ) f = [f useRecursive];
      else if ( argv[1][0] == 'i' ) f = [f useIterative];
      else fprintf(stderr, "Don't recognize %c, using default.\n", argv[1][0] );
   }
   else if ( argc != 1 ) 
   {
      fprintf( stderr, "Usage: %s [r|i] [integer]\n", argv[0]);
      return 1;
   }
   
   
   answer = [f computeNew: n];
   fprintf(stderr,"fib(%d)=%d\n", n, answer );

   return 0;
}
