ios设计一部WindowsPhone手机

来源:互联网 发布:软件用户license设计 编辑:程序博客网 时间:2024/04/30 02:23

ios设计一部WindowsPhone手机

main.m

#import <Foundation/Foundation.h>#import "WindowsPhone.h"int main(int argc, const char * argv[]){    WindowsPhone * phone = [WindowsPhone new];    phone->_color = WindowsPhoneColorGolden;    phone->_size = 3.5;    NSLog(@"%@",phone);    [phone cameraWithFlashLightSatuts:WindowsPhoneFlashLightStatusOpen];            @autoreleasepool {                // insert code here...        //NSLog(@"Hello, World!");            }    return 0;}

WindowsPhone.h

#import <Foundation/Foundation.h>enum WindowsPhoneSize{    WindowsPhoneSize3Point5,//屏幕尺寸3.5    WindowsPhoneSize4Point0,//屏幕尺寸4.0    WindowsPhoneSize5Point5,//屏幕尺寸5.5    WindowsPhoneSize6Point0 //屏幕尺寸6.5};typedef enum WindowsPhoneSize WindowsPhoneSize;enum WindowsPhoneColor{    WindowsPhoneColorWhite,//用来存储WidowsPhone的颜色白色    WindowsPhoneColorGolden,//用来存储WindowsPhone的颜色土豪金    WindowsPhoneColorBlack //用来存储WindowsPhone的颜色黑色};typedef enum WindowsPhoneColor WindowsPhoneColor;enum WindowsPhoneFlashLightStatus{    WindowsPhoneFlashLightStatusOpen,//闪关灯开    WindowsPhoneFlashLightStatusClose,//闪光灯关    WindowsPhoneFlashLightStatusAuto//自动模式};typedef enum WindowsPhoneFlashLightStatus WindowsPhoneFlashLightStatus;//记录电影播放的状态enum WindowsPhoneFilmPlayStatus{    WindowsPhoneFilmPlayStatusStart,//状态:开始播放    WindowsPhoneFilmPlayStatusPause,//状态:暂停播放    WindowsPhoneFilmPlayStatusFastSpeed,//状态:快进    WindowsPhoneFilmPlayStatusSlowSpeed, //状态:快退    WindowsPhoneFilmPlayStatusLastFilm,//状态:上一部    WindowsPhoneFilmPlayStatusNextFilm //状态:下一部    };typedef enum WindowsPhoneFilmPlayStatus WindowsPhoneFilmPlayStatus;@interface WindowsPhone : NSObject{    @public    /**用来存储WindowsPhone的颜色*/    WindowsPhoneColor _color;        /**用来存储WindowsPhone的尺寸大小*/    float _size;        /**用来存储WindowsPhone cpu的大小*/    float _cpu;    /**用来存储WindowsPhone ram内部存储的大小*/    float _ram;}//setter 方法-(void)setWindowsPhoneSize:(float)size;/**打开闪光灯*/-(void)openFlashLight;/**关闭闪光灯*/-(void)closeFlashLight;/**自动模式*/-(void)flaseLightAuto;/**拍照*/-(void)cameraWithFlashLightSatuts:(WindowsPhoneFlashLightStatus)flashLightStatus;/**看电影*/-(void)filmWithPlayStatus:(WindowsPhoneFilmPlayStatus)WindowsPhoneFilmPlayStatus;/**发邮件*/-(void)sendEmail;@end


WindowsPhone.m


#import "WindowsPhone.h"@implementation WindowsPhone/**打开闪光灯*/-(void)openFlashLight{    //打开闪光灯    NSLog(@"打开闪光灯");}/**关闭闪光灯*/-(void)closeFlashLight{    //关闭闪光灯    NSLog(@"关闭闪光灯");}/**自动模式*/-(void)flaseLightAuto{    //自动模式    NSLog(@"自动模式");}//拍照-(void)cameraWithFlashLightSatuts:(WindowsPhoneFlashLightStatus)flashLightStatus{    //self 关键字 谁调用指的就是谁 可以实现类的内部方法的调用    if(flashLightStatus == WindowsPhoneFlashLightStatusOpen)    {        [self openFlashLight];        //打开摄像头    }    else if(flashLightStatus==WindowsPhoneFlashLightStatusClose)    {        [self closeFlashLight];        //关闭摄像头    }    else    {        [self flaseLightAuto];        //自动模式    }        NSLog(@"拍照了!笑一个!");    //用switch来实现这个功能    /*    switch(flashLightStatus)    {            case WindowsPhoneFlashLightStatusOpen:            [self openFlashLight];            break;            case WindowsPhoneFlashLightStatusClose:            [self closeFlashLight];            break;            case WindowsPhoneFlashLightStatusAuto:            [self flaseLightAuto];            break;            default:            break;    }    */    }//看电影-(void)filmWithPlayStatus:(WindowsPhoneFilmPlayStatus)WindowsPhoneFilmPlayStatus{    if(WindowsPhoneFilmPlayStatus == WindowsPhoneFilmPlayStatusStart){        //开始播放电影        NSLog(@"开始播放电影");    }    else if (WindowsPhoneFilmPlayStatus == WindowsPhoneFilmPlayStatusPause)    {        //暂停播放        NSLog(@"暂停播放");    }    else if(WindowsPhoneFilmPlayStatus == WindowsPhoneFilmPlayStatusFastSpeed)    {        //快进        NSLog(@"快进");    }    else if(WindowsPhoneFilmPlayStatus == WindowsPhoneFilmPlayStatusSlowSpeed)    {        //快退        NSLog(@"快退");    }    else if(WindowsPhoneFilmPlayStatus==WindowsPhoneFilmPlayStatusLastFilm)    {        //上一部电影        NSLog(@"播放上一部电影");    }    else if(WindowsPhoneFilmPlayStatus == WindowsPhoneFilmPlayStatusNextFilm)    {        //下一部电影        NSLog(@"播放下一部电影");    }    else    {        //退出        NSLog(@"退出");    }    }//setter 方法-(void)setWindowsPhoneSize:(float)size{    _size = 3.5;}//重写description方法//这里重写方法要注意是重写的是对象方法还是类的方法//用来调试-(NSString *)description{    return [NSString stringWithFormat:@"size = %f cpu = %f ram = %f ",_size,_cpu,_ram];}@end


0 0