//
// 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: andWidth:];
[rect printArea];
}
return ;
}

OC3_MyRect的更多相关文章

随机推荐

  1. 简单dp-poj-2231-Moo Volume

    题目链接: http://poj.org/problem?id=2231 题目大意: 给n个位置,求所有位置到其他n-1个位置的距离总和. 解题思路: 简单dp. o(n^2)的时间复杂度会超.先对这 ...

  2. OpenCV入门学习笔记

    OpenCV入门学习笔记 参照OpenCV中文论坛相关文档(http://www.opencv.org.cn/) 一.简介 OpenCV(Open Source Computer Vision),开源 ...

  3. 如何检查机器是否因为装了Windows更新而需要重新启动

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何检查机器是否因为装了Windows更新而需要重新启动.

  4. 【Cocos2d-X开发学习笔记】第09期:渲染框架之菜单类(CCMenu)的使用

    本系列学习教程使用的是cocos2d-x-2.1.4(最新版为3.0alpha0-pre) ,PC开发环境Windows7,C++开发环境VS2010    一.菜单项(CCMenuItem) 菜单项 ...

  5. Tomcat无法部署项目

    设置项目的Jdk,compire version 增加java EE 如果有必要,现在项目根目录下放置.mymetadata文件 <?xml version="1.0" en ...

  6. getJSON的用法

    一.方法定义:jQuery.getJSON( url, data, callback ) 通过get请求得到json数据 ·url用于提供json数据的地址页 ·data(Optional)用于传送到 ...

  7. 假设有两个包含整数的vector对象,编写一段程序,检验其中一个vector对象是否是另一个的前缀。

    #include<iostream> #include<string> #include<vector> using namespace std; int main ...

  8. 在javascript中关于submit和button提交表单区别

    submit是button的一个特例,也是button的一种,它把提交这个动作自动集成了,submit和button,二者都以按钮的形式展现,看起来都是按钮,所不同的是type属性和处发响应的事件上. ...

  9. PHP中$_POST,$_GET,$_REQUEST,$_FILES全局变量的全局指什么

    我一直担心,同一个表单,同时提交2次会发生什么事?在服务器端表单变量会不会彼此覆盖呢?也就是说假如我们在PHP中用$_REQUEST["name"]访问某个表单变量,会不会因为别人 ...

  10. linux 查看文件命令总结

    linux 查看文件命令总结 1.cat 查看文件内容 选项-b 空白行不显示行号.-n,空白行显示 2.more 查看文件内容,通过空格键查看下一页 q键退出查看 3.less 和上同,多了方向键( ...