CINEMA.M implementation
#import "Cinema.h" @implementation cinema-(ID) init{//Call the parent class construction Method self = [super init]; Determines whether initialization succeeds if (self! = nil) {_name = nil;//is used to store the name of the movie _price = 0;//is used to store movie fares _ro Wnumber = 1;//used to store the number of seats _seatnumber = 1;//used to store the seat number _filmroom = filmroomwithone;//used to store the hall number} Return self to return self;} The declaration of the/*set\get method *//** provides a set method for the movie name */-(void) SetName: (NSString *) name{_name = name;} -(NSString *) name; {return _name;} /** provides a set method for movie fares */-(void) Setprice: (int) price{if (Price > 0) {_price = Price; }}-(int) price{return _price;} /** provides a set method for the number of cinema bits */-(void) Setrownumber: (int) rownumber{if (RowNumber > 0 && rowNumber < one) {_row Number = RowNumber; }}-(int) rownumber{return _rownumber;} /** the Set method of providing the hall seat number */-(void) Setseatnumber: (int) seatnumber{if (Seatnumber > 0 && seatnumber<) {_s Eatnumber = Seatnumber; }}-(int) seatnumber{return _seatnumber;} /** Studio Select */-(void) Filmwithplayfileroom: (filmroom) filmroom{switch (filmroom) {case Filmroomwithone:nslog (@ "You chose 1th Cinema Hall "); Break Case Filmroomwithtwo:nslog (@ "You have chosen the 2nd Cinema Hall"); Break Case Filmroomwiththree:nslog (@ "You have chosen the 3rd Cinema Hall"); Break Case Filmroomwithfour:nslog (@ "You have chosen the 4th Cinema Hall"); Break Case Filmroomwithfive:nslog (@ "You have chosen the 5th Cinema Hall"); Break Case Filmroomwithsix:nslog (@ "You have chosen the 6th Cinema Hall"); Case Filmroomwithseven:nslog (@ "You have chosen the 7th Cinema Hall"); Break Default:nslog (@ "Please re-select!") Thank you "); Break }}nsstring * _name;//used to store the name of the movie int _price;//used to store the movie fare int _rownumber;//used to store the seating number int _seatnumber;//used to store the seat number Filmroom _ filmroom;//used to store the hall number/** override description Method */-(NSString *) description{return [NSString stringwithformat:@ movie name:%@ movie ticket price:%d Number of seats:%d seat number:%d Hall number:%d ", _name,_price,_rownumber,_seatnumber,_filmroom];} /* Class method implementation */+ (NSString*) Getfilmroom: (filmroom) filmroom{nsstring * * * * ""; Switch (filmroom) {Case filmroomwithone:room = @ "You have chosen the Hall of No. 1th"; Break Case filmroomwithtwo:room = @ "You selected the 2nd Hall"; Break Case filmroomwiththree:room = @ "You selected the 3rd Hall"; Break Case filmroomwithfour:room = @ "You selected the 4th Hall"; Break Case filmroomwithfive:room = @ "You selected the 5th Hall"; Break Case filmroomwithsix:room = @ "You selected the 6th Hall"; Case filmroomwithseven:room = @ "You selected the 7th Hall"; Break Default:room = @ "Please re-select!" Thank you "; Break } return to the hostel;} Custom constructor-(ID) initwithfilm: (Film *) film{self = [super init]; if (self! = nil) {_film = film; } return self;} -(void) Setfilm: (Film *) film{_film = Film;} -(Film *) film{return _film;} Establish a combined relationship between two classes-(Film *) Informationaboutfilm: (Film *) film{[Film Aboutthefilm]; return film;} @end
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
iOS Development Design Cinema