ap102 2016/4/29 OO implementation

ap102 2016/4/29 OO implementation

//  Student.m
//  HelloClass

#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

//  Student.h
//  HelloClass


#import <Foundation/Foundation.h>

@interface Student : NSObject

{
    //宣告物件變數(instance variable)
    NSString*name;
    int chineseScore;
    int mathScore;

}

@property (nonatomic)int
    englishScore;


-(NSString*)name;

-(void)setname:(NSString*)studentName;

-(void)setChineseScore:(int)score;//setter
-(int)chineseScore;//getter
-(int)mathScore;



@end
//
//  ViewController.m
//  HelloClass

#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

Popular posts from this blog

MEGA 暫存檔案刪除

IOS GCD多執行緒

利用CMD指令強制刪除