#import
typedef struct
{
int year;
int month;
int day;
int hour;
int minute;
int second;
} registerDate ;
@interface Account : NSObject
@property(nonatomic,retain)NSString *userName;
@property(nonatomic,retain)NSString *password;
@property(nonatomic,assign)registerDate date;
@end
#import “Account.h”
@implementation Account
#import
#import “Account.h”
typedef struct
{
int year;
int month;
int day;
int hour;
int minute;
int second;
} birthDay;
@interface User : NSObject
@property(nonatomic,retain)NSString *name;
@property(nonatomic,assign)birthDay birthDay;
@property(nonatomic,retain)Account *account;
@end
#import “User.h”
@implementation User
#import
#import “User.h”
typedef struct
{
int year;
int month;
int day;
int hour;
int minute;
int second;
} publishDate;
@interface Microblog : NSObject
@property(nonatomic,retain)NSString *content;
@property(nonatomic,retain)NSString *picURL;
@property(nonatomic,assign)publishDate date;
@property(nonatomic,retain)User *user;
@property(nonatomic,retain)Microblog *zfBlog;
@property(nonatomic,assign)int pingLunShu;
@property(nonatomic,assign)int zfShu;
@property(nonatomic,assign)int dzShu;
@end
#import “Microblog.h”
@implementation Microblog
#import
#import “User.h”
#import “Microblog.h”
int main(int argc, const char * argv[])
{
@autoreleasepool
{
User *zhangSan = [[[User alloc] init] autorelease];
Account *zhangSanAccount = [[[Account alloc] init] autorelease];
zhangSanAccount.userName = @“zhangSan”;
zhangSanAccount.password = @“123456”;
zhangSanAccount.date = (registerDate){2007,9,8,17,56,34};
zhangSan.birthDay = (birthDay){1998,7,4,18,46,24};
zhangSan.account = zhangSanAccount;
Microblog *zhangSanBlog01 = [[[Microblog alloc] init] autorelease];
zhangSanBlog01.content = @“今天心情不错。”;
zhangSanBlog01.picURL = @“goodDay.png”;
zhangSanBlog01.date = (publishDate){2010,8,8,9,23,44};
zhangSanBlog01.user = zhangSan;
zhangSanBlog01.pingLunShu = 100;
zhangSanBlog01.zfShu = 290;
zhangSanBlog01.dzShu = 2000;
User *liSi = [[[User alloc] init] autorelease];
Account *liSiAccount = [[[Account alloc] init] autorelease];
liSiAccount.userName = @"liSiAccount";
liSiAccount.password = @"654321";
liSiAccount.date = (registerDate){2006,9,8,19,26,54};
liSi.account = liSiAccount;
liSi.birthDay = (birthDay){1999,9,6,14,16,28};
Microblog *liSiBlog01 = [[[Microblog alloc] init] autorelease];
liSiBlog01.content = @"今天心情确实不错。";
liSiBlog01.date = (publishDate){2011,8,8,20,47,9};
liSiBlog01.user = liSi;
liSiBlog01.zfBlog = zhangSanBlog01;
liSiBlog01.pingLunShu = 10;
liSiBlog01.zfShu = 20;
liSiBlog01.dzShu = 200;
}
return 0;
}
题目要求如下:
设计1个微博app的部分类:
1.微博类(Microblog)
属性:
文字内容
图片
发表时间
作者
被转发的其他微博
评论数
转发数
点赞数
2.作者类(User)
属性:
名称
生日
账号
3.账号类(Account)
属性:
账号名称
账号密码
账号注册时间
在动手写之前,自我提问,这三个类应该先写哪个
模拟场景
1.张三在2007-9-8 17:56:34的时候,注册了一个账号(名称:zhangSan,密码:123456)
张三的生日是1998-7-4 18:46:24
张三在2010-8-8 9:23:44的时候,发布1条微博
文字内容:今天心情不错
图片:goodDay.png
发表时间
作者
被转发的其他微博
评论数 100
转发数 200
点赞数 2000
2.李四在2006-9-8 19:26:54的时候,注册了1个账号(名称:liSiAccount,密码:654321)
李四的生日 1999-9-6 14:16:28
李四在2010-8-8 20:47:09的时候,转发了张三之前发布的微博,并且还附带了1句话:今天心情确实不错
评论数 10
转发数 20
点赞数 200