zoukankan      html  css  js  c++  java
  • OC3_MyRect

    //
    //  MyRect.h
    //  OC3_MyRect
    //
    //  Created by zhangxueming on 15/6/9.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    
    @interface MyRect : NSObject
    {
        int _length;
        int _width;
    }
    
    - (id)initWithLength:(int)length andWidth:(int)width;
    
    - (int)length;
    
    - (int)width;
    
    - (void)setLength:(int)length andWidth:(int)width;
    
    - (int)area;
    
    - (void)printArea;
    
    @end
    //
    //  MyRect.m
    //  OC3_MyRect
    //
    //  Created by zhangxueming on 15/6/9.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import "MyRect.h"
    
    @implementation MyRect
    
    - (id)initWithLength:(int)length andWidth:(int)width
    {
        self = [super init] ;
        if (self) {
            _length = length;
            _width = width;
        }
        return self;
    }
    
    - (int)length
    {
        return _length;
    }
    
    - (int)width
    {
        return _width;
    }
    
    - (void)setLength:(int)length andWidth:(int)width
    {
        _length = length;
        _width = width;
    }
    
    - (int)area;
    {
        return [self length] * [self width];
    }
    
    - (void)printArea
    {
        NSLog(@"area = %i", [self area]);
    }
    
    @end
    //
    //  main.m
    //  OC3_MyRect
    //
    //  Created by zhangxueming on 15/6/9.
    //  Copyright (c) 2015年 zhangxueming. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    #import "MyRect.h"
    
    int main(int argc, const char * argv[]) {
        @autoreleasepool {
            MyRect *rect = [[MyRect alloc] init];
            [rect setLength:10 andWidth:5];
            [rect printArea];
        }
        return 0;
    }
  • 相关阅读:
    关于content-type请求头的说明
    RabbitMQ
    tornado
    flask总结之session,websocket,上下文管理
    爬虫相关问题总结
    爬虫之scrapy框架
    爬虫之Selenium模块
    爬虫之Beautifulsoup及xpath
    爬虫之requests
    SQLAlchemy
  • 原文地址:https://www.cnblogs.com/0515offer/p/4564541.html
Copyright © 2011-2022 走看看