iOS design a windowsphone phone
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,//Screen size 3.5 windowsphonesize4point0,//Screen Size 4.0 windowsphonesize5point5,//screen size 5.5 windowsphonesize6point0//Screen size 6.5};typedef Enum Windowsphonesize windowsphonesize;enum windowsphonecolor{windowsphonecolorwhite,//used to store the color of the Widowsphone white Window sphonecolorgolden,//used to store windowsphone color local tyrants Gold windowsphonecolorblack//used to store WindowsPhone color Black};typedef enum Windowsphonecolor windowsphonecolor;enum windowsphoneflashlightstatus{windowsphoneflashlightstatusopen,//flash off light off windowsphoneflashlightstatusclose,//Flash off windowsphoneflashlightstatusauto//automatic mode};typedef enum Windowsphoneflashlightstatus windowsphoneflashlightstatus;//Record the status of the movie playback enum windowsphonefilmplaystatus{ windowsphonefilmplaystatusstart,//Status: Start playback windowsphonefilmplaystatuspause,//status: Pause Playback windowsphonefilmplaystatusfastspeed,//Status: Fast Forward windowsphonefilmplaystatusslowspeed,//Status: Rewind windowsphonefilmplaystatuslastfilm,//Status: Prev WiNdowsphonefilmplaystatusnextfilm//Status: Next};typedef enum Windowsphonefilmplaystatus windowsphonefilmplaystatus;@ Interface windowsphone:nsobject{@public/** used to store the color of the windowsphone * * Windowsphonecolor _color; /** is used to store the size of the windowsphone */float _size; /** is used to store the size of the WindowsPhone CPU */float _CPU; /** is used to store the size of WindowsPhone RAM internal storage */float _ram;} Setter Method-(void) Setwindowsphonesize: (float) size;/** open flash */-(void) openflashlight;/** turn off Flash */-(void) closeflashlight;/** automatic mode */-(void) flaselightauto;/** photo */-(void) Camerawithflashlightsatuts: ( windowsphoneflashlightstatus) flashlightstatus;/** Watch movie */-(void) Filmwithplaystatus: (Windowsphonefilmplaystatus) windowsphonefilmplaystatus;/** e-mail */-(void) sendEmail; @end
Windowsphone.m
#import "WindowsPhone.h" @implementation windowsphone/** open Flash */-(void) openflashlight{//Turn on Flash NSLog (@ "Turn on Flash");} /** Turn off Flash */-(void) closeflashlight{//Turn off Flash NSLog (@ "Turn off Flash");} /** Auto mode */-(void) flaselightauto{//Auto mode NSLog (@ "auto mode");} Photo-(void) Camerawithflashlightsatuts: (windowsphoneflashlightstatus) flashlightstatus{//self keyword who is calling to refer to WHO You can implement the call of the internal method of the class if (Flashlightstatus = = Windowsphoneflashlightstatusopen) {[Self openflashlight]; Open Webcam} else if (flashlightstatus==windowsphoneflashlightstatusclose) {[Self closeflashlight]; Close the camera} else {[self flaselightauto]; Auto mode} NSLog (@ "Take a picture! Smile one! "); Use switch to implement this function */switch (flashlightstatus) {case Windowsphoneflashlightstatusopen: [Self Openflashlight]; Break Case Windowsphoneflashlightstatusclose: [Self closeflashlight]; Break Case WindowsphoneflashlightstatusauTo: [Self flaselightauto]; Break Default:break; } */}//Watch movie-(void) Filmwithplaystatus: (windowsphonefilmplaystatus) windowsphonefilmplaystatus{if (windowsphonefilmp Laystatus = = Windowsphonefilmplaystatusstart) {//start playing movie NSLog (@ "Start movie"); } else if (windowsphonefilmplaystatus = = Windowsphonefilmplaystatuspause) {//Pause playback NSLog (@ "pause playback"); } else if (windowsphonefilmplaystatus = = windowsphonefilmplaystatusfastspeed) {//Fast forward NSLog (@ "Fast forward"); } else if (windowsphonefilmplaystatus = = windowsphonefilmplaystatusslowspeed) {//Rewind NSLog (@ "Rewind"); } else if (windowsphonefilmplaystatus==windowsphonefilmplaystatuslastfilm) {//previous movie NSLog (@ "Play previous movie") ; } else if (windowsphonefilmplaystatus = = windowsphonefilmplaystatusnextfilm) {//Next movie NSLog (@ "Play next movie" ); } else {//exit NSLog (@ "exit"); }}//setter Method-(VOID) setwindowsphonesize: (float) size{_size = 3.5;} Overriding the description method//Here is the overriding method to note whether the object method or class method is overridden//used for debugging-(NSString *) description{return [NSString stringwithformat:@ " Size =%f CPU =%f ram =%f ", _size,_cpu,_ram];} @end
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS design a windowsphone phone