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



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值