ios开发之电子优惠券的设计与实现

// // main.m // 电子优惠券 // #import <Foundation/Foundation.h> #import "Discount.h" #import "Food.h" int main(int argc, const char * argv[]) { Discount * dis = [[Discount alloc]init]; [dis showInformation:20 andDiscountTime:@"本优惠券每日上午10:30之后使用" andContentInformation:@"本优惠券仅限在中国大陆地区售卖优惠券产品的麦当劳餐厅使用,具体以本店内公示为准,有效期2013年12月4日-2013年12月30日;涂改或损坏无效;食品以实物为准,图片仅供参考;本优惠券不合适用于送餐服务;除食物外,其他物品(包括容器)不在售卖范围;本优惠券不能与其他优惠活动同时使用"]; @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); } return 0; } 
// // Discount.h // 电子优惠券 // #import <Foundation/Foundation.h> @interface Discount : NSObject { /**用来记录打折价格*/ int _price; /**用来记录打折使用的时间*/ NSString * _discountTime; /**最终解释权信息*/ NSString * _contentInformation; } @property int price; @property NSString * discountTime; @property NSString * contentInformation; -(void)showInformation:(int)price andDiscountTime:(NSString *)discountTime andContentInformation:(NSString *)contentInformation; @end 

// // Discount.m // 电子优惠券 // #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(@"价格:%d 打折时间:%@ 详细介绍:%@",_price,_discountTime,_contentInformation); } -(NSString *)description { return [NSString stringWithFormat:@"价格:%d 打折时间:%@ 详细信息%@",_price,_discountTime,_contentInformation]; } @end 
// // Food.h // 电子优惠券 // #import <Foundation/Foundation.h> @interface Food : NSObject { /**用来记录菜品名称*/ NSString * _foodName; /**组成材料*/ NSString * _material; /**营养信息*/ NSString * _nutrition; /**用来记录食品种类*/ 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 // 电子优惠券 // #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:@"食品名称:%@食材:%@ 营养物质:%@",_foodName,_material,_nutrition]; } @end 

原文链接:https://blog.csdn.net/u012701023/article/details/46980349?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165277499316781683913601%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165277499316781683913601&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-15-46980349-null-null.nonecase&utm_term=%E4%BC%98%E6%83%A0

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
文明发言,共建和谐米科社区
提交
头像

昵称

取消
昵称表情图片