The previous cinema ticketing system has been improved to encapsulate the data as it should be, ensuring the security of the data.
To provide users with only the use of the interface
design and implementation of main.m//Cinema//#import <Foundation/Foundation.h> #import "Cinema.h" int main (int argc, const char * argv[]) { @autoreleasepool { //1. Create Object cinema * Cinema = [[Cinema new]init]; 2. Print the video message [Cinema movieinformation]; 3. The user chooses the movie [Cinema Selectmovie]; 4. The user chooses automatic arranging [cinema selectrownumber]; 5. The user chooses the seat [cinema Selectseatnumber]; 6. Print the ticket [cinema printTicket]; } return 0;}
////cinema.h//Cinema Design and implementation//#import <Foundation/Foundation.h> @interface Cinema: nsobject{int _movienumber;//movie number int _rownumber;//automatic arranging int _seatnumber;//seat number}//See video-(void) movieinformation;//Select Movie-( void) selectmovie;//Select Automatic Arranging-(void) selectrownumber;//Select seat number-(void) selectseatnumber;//ticket-(void) printTicket; @end
design and implementation of cinema.m//Cinema//#import "Cinema.h" @implementation cinema//-(void) movieinformation{ NSLog (@ "title:%@\n Release Date:%@\n Movie Duration:%@\n Actor:%@\n Director:%@\n film Number:%@", @ "no Man's Land", @ "December 24, 2013", @ "116 minutes", @ "Andy Lau, Huang Ye", @ "Zhang Yimou", @ "1");} Select Movie-(void) selectmovie{ //1. Prompt user to enter NSLog (@ "--Please select Movie--"); int movienumber = 0; scanf ("%d", &movienumber); 2. Record user input information _movienumber = Movienumber;} Select Automatic arranging-(void) selectrownumber{ NSLog (@ "Total 10 rows, no row 20 seats"); 1. Prompt the user to select Automatic arranging NSLog (@ "--Please select automatic arranging--"); int rowNumber = 0; scanf ("%d", &rownumber); 2. Record user input information _rownumber = RowNumber;} Select seat number-(void) selectseatnumber{ //1. Prompt with the seat number selected NSLog (@ "-Please select seat number--"); int seatnumber = 0; scanf ("%d", &seatnumber); 2. Record user input information _seatnumber = Seatnumber;} Ticket-(void) printticket{ NSLog (@ "Movie:%d%d rows%d", _movienumber,_rownumber,_seatnumber);} @end
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Design and implementation of cinema (improved update)