ap102 2016/4/29 OO implementation
#import "Student.h"
@implementation Student
-(NSString*)name
{
return name;
}
-(void)setname:(NSString*)studentName
{
name = studentName;
}
-(int)chineseScore:(int)StudentChineseScore
{
return StudentChineseScore;
}
-(int)mathScore:(int)StudentmathScore
{
return StudentmathScore;
}
-(void)setChineseScore:(int)score{
chineseScore = score;
}
@end
#import <Foundation/Foundation.h>
@interface Student : NSObject
{
NSString*name;
int chineseScore;
int mathScore;
}
@property (nonatomic)int
englishScore;
-(NSString*)name;
-(void)setname:(NSString*)studentName;
-(void)setChineseScore:(int)score;
-(int)chineseScore;
-(int)mathScore;
@end
#import "ViewController.h"
#import "Student.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)goPressed:(UIButton *)sender {
Student * glee = [[Student alloc] init];
[glee setname:@"123"];
[glee setChineseScore:90];
NSString * vir =[glee name];
NSLog(@"%@",vir);
[glee chineseScore];
[glee mathScore];
};
@end
Comments
Post a Comment