Day.01.15 乐器例子 main

#import 

#import "Piano.h"
#import "Instrment.h"
#import "Violin.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {

        enum PlayI {
        
            piano = 1,
            violin
        };
        
        enum PlayI instrmentpaly;
        
        
        
        NSLog(@"请选择乐器:(1.钢琴   2.小提琴)");
        
        scanf("%d",&instrmentpaly);
        
        
        
        
        Instrment *instrment;
        
        if (instrmentpaly == piano) {
            
            instrment = [[Piano alloc]init];
            
        }else if (instrmentpaly == violin) {
        
            instrment = [[Violin alloc]init];
        }
        
        
        [instrment play];
        
        
    
    }
    return 0;
}

你可能感兴趣的:(Day.01.15 乐器例子 main)