//
// Collegestudent.m
// oc-03继承,初始化方法,便利构造器
//
// Created by dllo on 15/10/26.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "Collegestudent.h"
@implementation Collegestudent
- (void)setFriend:(NSString *)friend
{
_friend = friend;
}
- (void)setPhonenumber:(NSString *)phoneNumber
{
_phoneNumber = phoneNumber;
}
- (NSString *)friend
{
return _friend;
}
- (NSString *)phoneNumber
{
return _phoneNumber;
}
- (void)info
{
[super info];
NSLog(@"%@%@", _friend, _phoneNumber);
}
//便利构造器
+ (id)collegestudentWithName:(NSString *)name sex:(NSString *)sex hobby:(NSString *)hobby score:(NSInteger)score friend:(NSString *)friend phoneNumber:(NSString *)phoneNumber
{
Collegestudent *p = [[Collegestudent alloc]initWithName:name sex:sex hobby:hobby score:score friend:friend phoneNumber:phoneNumber];
return p;
}
//初始化
- (id)initWithName:(NSString *)name sex:(NSString *)sex hobby:(NSString *)hobby score:(NSInteger)score friend:(NSString *)friend phoneNumber:(NSString *)phoneNumber
{
self = [super initWithName:name sex:sex hobby:hobby score:score];
if (self) {
// _friend = friend;
// _phoneNumber = phoneNumber;
[self setFriend:friend];
[self setName:name];
[self setPhonenumber:phoneNumber];
}
return self;
}
@end