Design and Implementation of Electronic coupons for ios development
/// Main. m // electronic coupon // # import
# Import Discount. h # import Food. hint main (int argc, const char * argv []) {Discount * dis = [[Discount alloc] init]; [dis showInformation: 20 andDiscountTime: @ This coupon uses andContentInformation after every day: @ This coupon is only available for McDonald's restaurants that sell coupon products in mainland China. This coupon is only available in the public shop and is valid from January 1, December 4-20, 2013 to January 1, December 30; invalid alteration or damage; food is subject to the actual product, and images are for reference only; this coupon is not suitable for food delivery services; other items (including containers) except food are not available for sale; this coupon cannot be used together with other promotions]; @ autoreleasepool {// insert code here... NSLog (@ Hello, Worl D !); } Return 0 ;}
/// Discount. h // electronic coupon // # import
@ Interface Discount: NSObject {/** used to record the Discount price */int _ price;/** used to record the Discount time */NSString * _ discountTime; /** final interpretation right information */NSString * _ contentInformation;} @ property int price; @ property NSString * discountTime; @ property NSString * contentInformation;-(void) showInformation :( int) price andDiscountTime :( NSString *) discountTime andContentInformation :( NSString *) contentInformation; @ end
//// Discount. m // electronic coupon // # import Discount. h @ implementation Discount @ synthesize price = _ price; @ synthesize discountTime = _ discountTime; @ synthesize contentInformation = _ contentInformation;-(void) showInformation :( int) price andDiscountTime :( NSString *) discountTime andContentInformation :( NSString *) contentInformation {_ price = price; _ discountTime = discountTime; _ contentInformation = contentInformation; NSLog (@ price: % d discount time: % @ details: % @, _ price, _ discountTime, _ contentInformation);}-(NSString *) description {return [NSString stringWithFormat: @ price: % d discount time: % @ details % @, _ price, _ discountTime, _ contentInformation];} @ end
/// Food. h // electronic coupon // # import
@ Interface Food: NSObject {/** is used to record the Dish name */NSString * _ foodName;/** composition material */NSString * _ material; /** nutrition information */NSString * _ nutrition;/** used to record the food type */NSString * _ kindOfFood;} @ property NSString * foodName; @ property NSString * material; @ property NSString * nutrition; @ property NSString * kindOfFood;-(void) showInformation :( NSString *) foodName andShowMaterial :( NSString *) material andShowNurition :( NSString *) nutrition; @ end
//// Food. m // electronic coupon // # import Food. h @ implementation Food @ synthesize foodName = _ foodName; @ synthesize material = _ material; @ synthesize nutrition = _ nutrition; @ synthesize kindOfFood = _ kindOfFood;-(void) showInformation :( NSString *) foodName andShowMaterial :( NSString *) material andShowNurition :( NSString *) nutrition; {_ foodName = foodName; _ material = material; _ nutrition = nutrition; NSLog (@ % @, _ foodName, _ material, _ nutrition);}-(NSString *) description {return [NSString stringWithFormat: @ food name: % @ ingredients: % @ nutrients: % @, _ foodName, _ material, _ nutrition];} @ end