oc加强day01作业答案

题目

/**
1. 说说类
* 文字内容
* 图片
* 发表时间
* 作者
* 转发的说说
* 评论数
* 转发数
* 点赞数

  1. 作者

    • 名称
    • 生日
    • 账号
  2. 账号

    • 账号名称
    • 账号密码
    • 账号注册时间

    模拟场景:

    • 张三在2007-9-8 17:56:34的时候, 注册了一个账号(名称:itcast, 密码:123456)
    • 张三的生日是1998-7-4 18:46:24
    • 张三在2010-8-8 9:23:44的时候, 发布一条说说
    • 文字内容 @“今天心情不错”
    • 图片 @“test.png”
    • 发表时间
    • 作者
    • 转发的说说
    • 评论数 100
    • 转发数 290
    • 点赞数 2000

    • 李四在2006-9-8 19:26:54的时候, 注册了一个账号(名称:lisiitcast, 密码:654321)

    • 李四的生日是1999-9-6 14:16:28
    • 李四在2011-8-8 20:47:09的时候, 转发了张三之前发布的说说, 并且还附带了一句话:@“今天心情确实不错”
      */

    blog.h

#ifndef blog_h
#define blog_h

#import <Foundation/Foundation.h>

//账号类
@interface CzxxAcc: NSObject
{
@private
    NSString * _accName;
    NSString * _accPassword;
    NSString * _accRegTime;


}

@property (nonatomic,copy) NSString * accName;

@property (nonatomic,copy) NSString * accPassword;

@property (nonatomic,copy) NSString * accRegTime;

-(id)initWithAccName:(NSString *) pAccname
     andPass:(NSString *) accPass
     andRegTime:(NSString *) Time;
@end

//作者类
@interface CzxxAuthor: NSObject
{
@private
    NSString * _name;
    NSString * _birth;
    CzxxAcc * _account;

}

@property (nonatomic,copy) NSString * name;

@property (nonatomic,copy) NSString * birth;

@property (nonatomic,strong) CzxxAcc * account;

@end

//说说类
@interface CzxxQzone: NSObject
{
@private
    NSString * _blogContents;
    NSString * _blogPics;
    NSString * _blogSendTime;
    CzxxAuthor * _blogAuthor;
    CzxxQzone * _blogCopy;
    int _commentsNums;
    int _copyNums;
    int _likeNums;

}
@property (nonatomic,copy) NSString * blogContents;

@property (nonatomic,copy) NSString * blogPics;

@property (nonatomic,copy) NSString * blogSendTime;

@property (nonatomic,strong) CzxxAuthor * blogAuthor;

@property (nonatomic,strong) CzxxQzone * blogCopy;

@property (nonatomic,assign) int commentsNums;

@property (nonatomic,assign) int copyNums;

@property (nonatomic,assign) int likeNums;

-(NSString *)description;

@end
#endif /* blog_h */

blog.m

#import <Foundation/Foundation.h>
#import "blog.h"


@implementation CzxxAcc

-(id)initWithAccName:(NSString *) pAccname
             andPass:(NSString *) accPass
          andRegTime:(NSString *) Time
{
    if(self = [super init])
    {
        self.accName = pAccname;
        self.accPassword = accPass;
        self.accRegTime = Time;
    }

    return self;
}
@end

@implementation CzxxAuthor
@end


@implementation CzxxQzone

@synthesize blogContents = _blogContents;

@synthesize blogPics = _blogPics;

@synthesize blogSendTime = _blogSendTime;

@synthesize blogAuthor = _blogAuthor;

@synthesize blogCopy = _blogCopy;

@synthesize commentsNums = _commentsNums;

@synthesize copyNums = _copyNums;


-(NSString *)description
{
    NSString * str = [NSString stringWithFormat:@"blogContents is %@\n andPic is%@ \n and sendTime  is %@\n and andAuthName is %@\n and AuthBirth is %@\n AccName is %@\n and AccPass is %@ and accRegTime is%@  andblogCopy conTent is%@ and Copy from %@\n",_blogContents,_blogPics,_blogSendTime,_blogAuthor.name,_blogAuthor.birth,_blogAuthor.account.accName,_blogAuthor.account.accPassword,_blogAuthor.account.accRegTime,_blogCopy.blogContents,_blogCopy.blogAuthor.name];
    return str; 
}

@end

main.m

#import <Foundation/Foundation.h>
#import "blog.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        CzxxAcc * acc_zhangsan = [[CzxxAcc alloc] initWithAccName:@"itcast" andPass:@"123456" andRegTime:@"2007-9-8 17£∫56£∫34" ];

        CzxxAuthor * auth_zhangsan = [[CzxxAuthor alloc] init];
        auth_zhangsan.name = @"张三˝";
        auth_zhangsan.birth = @"11998-7-4 18:46:24";
        auth_zhangsan.account = acc_zhangsan;

        CzxxQzone * blog_zhangsan = [[CzxxQzone alloc] init];
        blog_zhangsan.blogContents = @"今天心情不错";
        blog_zhangsan.blogPics = @"test.png";
        blog_zhangsan.blogSendTime = @"2010-8-8 9:23:44";
        blog_zhangsan.blogAuthor = auth_zhangsan;
        blog_zhangsan.blogCopy = nil;
        blog_zhangsan.commentsNums = 100;
        blog_zhangsan.copyNums = 290;
        blog_zhangsan.likeNums = 2000;

        NSLog(@"%@",blog_zhangsan);

        CzxxAcc * acc_lishi = [[CzxxAcc alloc] initWithAccName:@"lisiitcast" andPass:@"654321" andRegTime:@"2006-9-8 19£∫26£∫54" ];
        CzxxAuthor *author_lishi = [[CzxxAuthor alloc] init];
        author_lishi.name = @"李四";
        author_lishi.birth = @"1999-9-6 14:16:28";
        author_lishi.account = acc_lishi;

        CzxxQzone * blog_lishi = [[CzxxQzone alloc] init];
        blog_lishi.blogContents = @"今天确实心情不错";
        blog_lishi.blogPics = nil;
        blog_lishi.blogSendTime = @"2011-8-8 20:47:09";
        blog_lishi.blogAuthor = author_lishi;
        blog_lishi.blogCopy = blog_zhangsan;//ƒø«∞√ª”–◊™∑¢
        blog_lishi.commentsNums = 0;
        blog_lishi.copyNums = 0;
        blog_lishi.likeNums = 0;
        NSLog(@"%@",blog_lishi);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值