欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

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

来源: 开发者 投稿于  被查看 24506 次 评论:265

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


//
//  main.m
//  电子优惠券
//


#import 
#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 

@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 

@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


 

用户评论