码迷,mamicode.com
首页 > 其他好文 > 详细

object-c review

时间:2017-08-21 17:25:10      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:min   object   ice   copyright   logs   []   price   info   review   

//
//  main.m
//  cmdTry
//
//  Created by Calos Chen on 2017/8/21.
//  Copyright © 2017年 Calos Chen. All rights reserved.
//

#import <Foundation/Foundation.h>

@class Fraction;
@interface Fraction : NSObject
{
    int numberator;
    int denominator;
    NSString* name;
    double price;
    Fraction *myf;
}
@property double price;
-(void) print;
-(void) setNumberator: (int)n;
-(void) setName: (NSString*)na;
-(void) setInfo: (int) id name:(NSString*)name;


@end

@implementation Fraction

@synthesize price;

-(void) print
{
    NSLog(@"%i it is %@",numberator,name);
}
-(void) setNumberator:(int)n
{
    price=5;
    numberator=n;
}
-(void)setName:(NSString *)na{
    name=na;
}

-(void) setInfo:(int)id name:(NSString *)na{
    id=id;
    name=na;
}

@end

//---- program section ----

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSLog(@"Hello, World!");
        NSLog(@"who are you!");
    }
    
    NSLog(@"why is it");
    Fraction *myf= [[Fraction alloc] init];
    [myf setName:@"calos"];
    [myf print];
    
    int a1=5;
    float a2=3.23;
    double a3=3.44;
    char a4=‘c‘;
    int a5=(int)a2;
    for (int b=1; b<10;b++ ) {
        a5+=b;
    }
    myf.price=88;
    double b1=myf.price;
    BOOL isPrime=NO;
    NSLog(@"%i %f %e %c %i %c %g",a1,a2,a3,a4,a5,isPrime,b1);
    NSLog(@"end........");
    
    
    
    
    return 0;
}

//for today: 2017-08-21, I have read and practiced the first 153 pages of the object-c 2.0, now, I have known object-c classes and data types, and how to announce and implement the classes and class members, as well as functions in the class implementation. also property synthesize methods. loops.
//homework: implement a new class, and new interface and fill the class with members and all tangible members, then use all of them. @class declaration. So, write a console program with object-c.

 

object-c review

标签:min   object   ice   copyright   logs   []   price   info   review   

原文地址:http://www.cnblogs.com/hualiu0/p/7405517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!