IOS开发之微博的设计与实现

//
// main.m
// Microblog
// #import <Foundation/Foundation.h>
#import "Person.h"
#import "BlogMaster.h" #import "Microblog.h" int main(int argc, const char * argv[])
{
Person * person = [[Person alloc]init]; [person showName]; NSLog(@"%@",person); Person * man = [[Person alloc]init]; [man showName]; //Microblog * microblog = [[Microblog alloc]init]; return 0;
}
#import <Foundation/Foundation.h>

@interface Person : NSObject
{
/**用来记录人的名字*/
NSString * _name; /**用来记录人的年龄*/
int _age; /**用来记录出生年月*/
NSString * _birthday; /**用来记录性别*/
char _sex; /**用来记录所在地*/
NSString * _address; /**用来记录感情状况*/
NSString * _emotion; /**用来记录血型*/
NSString * _bloodType;
}
@property NSString * name;
@property int age;
@property NSString * birthday;
@property char sex;
@property NSString * address;
@property NSString * emtion;
@property NSString * bloodType; -(void)showName; @end
#import "Person.h"
#import <Foundation/Foundation.h>
@implementation Person -(void)showName
{
NSLog(@"打印人的名字");
//NSLog(@"%@",_name);
} -(NSString *)description
{
return [NSString stringWithFormat:@"名字=%@ 年龄=%d 出生日期=%@性别=%c 住址=%@ 感情状况=%@ 血型=%@",_name,_age,_birthday,_sex,_address,_emotion,_bloodType]; }
@end
#import <Foundation/Foundation.h>
#import "BlogMaster.h"
#import "Person.h"
@interface Microblog : NSObject
{
/**用来存储博主信息*/
//BlogMaster * _blogMaster; /**用来存储注冊时间*/
NSString * _registerTime; /**简单介绍*/
NSString * _introductionAboutBlog; /**用来记录博客内容*/
NSString * _blogContent; /**用来记录评论内容*/
NSString * _commentContent; /**用来记录评论数量*/
int _commentAmount; /**用来记录点赞数量*/
int _praiseAmount; /**用来记录微博发表时间*/
NSString * _publishTime; /**用来记录转发数量*/
int _transpond;
} @property NSString * registerTime;
@property NSString * introductionAboutBlog;
@property NSString * blogContent;
@property NSString * commentContent;
@property NSString * publishTime;
@property int commentAmount;
@property int praiseAmount;
@property int transpond; //-(void)printBlogMasterName:(Person *)person; @end
#import "Microblog.h"

@implementation Microblog

//-(void)printBlogMasterName:(Person *)person
//{
// if([Person isKindOfClass:[BlogMaster class]])
// {
// BlogMaster * master = (BlogMaster *)person;
// }
// [master showName];
//} -(NSString *)description
{
return [NSString stringWithFormat:@" 博客内容=%@ 评论数量=%d 点赞数量=%d 发表时间=%@ 转发数量=%d",_blogContent,_commentAmount,_praiseAmount,_publishTime,_transpond];
}
@end
#import "Person.h"

@interface BlogMaster : Person
{ }
-(void)showName; @end
#import "BlogMaster.h"

@implementation BlogMaster
-(void)showName
{
NSLog(@"博主的名字");
}
@end
上一篇:python3-cookbook笔记:第二章 字符串和文本


下一篇:eclipse + marven