Design and Implementation of IPad for iOS development
//// main.m// 6-ipad//#import
#import Ipad.hint main(int argc, const char * argv[]){ Ipad * ipad = [Ipad new]; ipad->_color = IpadColorBlack; ipad->_size = 7.9; NSLog(@%@,ipad); [ipad cameraWithFlashLightSatuts:IpadFlashLightStatusOpen]; return 0;}
# Import
Enum IpadSize {IpadSize9Point5, // screen size: 9.5 IpadSize7Point9, // screen size: 7.9}; typedef enum IpadSize; enum IpadColor {IpadColorWhite, // used to store the color of the Ipad white IpadColorBlack // used to store the color of the Ipad black}; typedef enum IpadColor; enum IpadFlashLightStatus {IpadFlashLightStatusOpen, // enable IpadFlashLightStatusClose, // flash off IpadFlashLightStatusAuto // automatic mode}; typedef enum IpadFlashLightStatus; // record the video playback status enum IpadFilmPlayStatus {IpadFilmPlayStatusStart, // status: start playback pending, // status: pause IpadFilmPlayStatusFastSpeed, // status: Fast forward to IpadFilmPlayStatusSlowSpeed, // status: IpadFilmPlayStatusLastFilm, // status: previous deployment // status: Next Generation}; typedef enum IpadFilmPlayStatus; @ interface Ipad: NSObject {@ public/** is used to store the color of the Ipad */IpadColor _ color;/** is used to store the size of the Ipad */float _ size; /** used to store the Ipad cpu size */float _ cpu;/** used to store the size of the Ipad ram internal storage */float _ ram ;} // setter method-(void) setIpadSize :( float) size;/** turn on the flashlight */-(void) openFlashLight;/** turn off the flashlight */-(void) closeFlashLight; /** automatic mode */-(void) flaseLightAuto;/** take a photo */-(void) cameraWithFlashLightSatuts :( IpadFlashLightStatus) flashLightStatus;/** watch a movie */-(void) filmWithPlayStatus :( IpadFilmPlayStatus) IpadFilmPlayStatus;/** send an email */-(void) downLoadSoft;-(void) installSoft;-(void) playGame;-(void) listen;-(void) searchInformation;-(void) editWord; @ end
# Import Ipad. h @ implementation Ipad-(id) init {self = [super init]; if (self! = Nil) {_ cpu = 1.5; _ ram = 1024;} return self;}/** turn on the flashlight */-(void) openFlashLight {// enable the flashlight NSLog (@ enable the flashlight);}/** disable the flashlight */-(void) closeFlashLight {// disable the flashlight NSLog (@ disable the flashlight );} /** automatic mode */-(void) flaseLightAuto {// automatic mode NSLog (@ automatic mode);}-(void) sendEmail {} // photograph-(void) cameraWithFlashLightSatuts :( IpadFlashLightStatus) flashLightStatus {// the keyword "who calls" indicates who can call internal methods of the class if (flashLightStatus = IpadFlashLightStatusOpen) {[self openFlashLight]; // open the camera} else if (flashLightStatus = IpadFlashLightStatusClose) {[self closeFlashLight]; // close the camera} else {[self flaseLightAuto]; // automatic mode} NSLog (@ );} // watch a movie-(void) filmWithPlayStatus :( IpadFilmPlayStatus) IpadFilmPlayStatus {if (IpadFilmPlayStatus = IpadFilmPlayStatusStart) {// start playing the NSLog (@ start playing the movie);} else if (IpadFilmPlayStatus = IpadFilmPlayStatusPause) {// pause playing NSLog (@ pause PLAYING );} else if (IpadFilmPlayStatus = IpadFilmPlayStatusFastSpeed) {// fast forward NSLog (@ fast forward);} else if (IpadFilmPlayStatus = forward) {// fast return NSLog (@ fast return );} else if (IpadFilmPlayStatus = IpadFilmPlayStatusLastFilm) {// NSLog of the previous movie (@ Play the previous movie);} else if (IpadFilmPlayStatus = IpadFilmPlayStatusNextFilm) {// NSLog of the next movie (@ play the next movie);} else {// exit NSLog (@ quit) ;}// setter method-(void) setIpadSize :( float) size {_ size = 3.5;}-(void) downLoadSoft {}- (void) installSoft {}- (void) playGame {}- (void) listen {}-(void) searchInformation {}-(void) editWord {} // override description method // here, the rewrite method should be noted whether it is an object method or a class method // used for debugging-(NSString *) description {return [NSString stringWithFormat: @ size = % f cpu = % f ram = % f, _ size, _ cpu, _ ram];} @ end