//
// 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. MSSQLSERVER数据库- 作业调度定时备份数据库

    作业调度和备份数据库是常见的行为,掌握这两项技术我觉的非常有必要. 在网上找到这个示例,记录在这里 备份数据库的SQL语句 --自动备份并保存最近5天的SQL数据库作业脚本 ) DECLARE @da ...

  2. C#中让窗体自动靠边隐藏

    1: private void Yincangtimer_Tick(object sender, EventArgs e)//窗体隐藏事件 2: { 3: int a = Control.MouseP ...

  3. 剑指OFFER之树的子结构(九度OJ1520)

    题目描述: 输入两颗二叉树A,B,判断B是不是A的子结构. 输入: 输入可能包含多个测试样例,输入以EOF结束.对于每个测试案例,输入的第一行一个整数n,m(1<=n<=1000,1< ...

  4. 有如下Student 对象,  private String name;       private int age;       private int score;   private String classNum;  其中,classNum

    package homework003; import java.util.ArrayList; import java.util.List; public class Text { public s ...

  5. 使用CATransition实现页面的“从左向右” “从右向左”的动画

    -(void)initView{ UISwipeGestureRecognizer *left_gesture=[[UISwipeGestureRecognizer alloc]initWithTar ...

  6. Lotus分析

    一 Lotus的任务 Lotus是一个消息通知服务,topic和subscription是多对多的关系.后面我加了一个发送自定义邮件和自定义短信的功能. 产品里面有个监控报警和通知列表.监控报警里创建 ...

  7. 常见排序算法及其java实现

    最近学习了下java,感觉java在基本语法上与C++非常相似.作为练习,我用java实现了冒泡排序.选择排序.插入排序.基尔排序.快速排序.堆排序.计数排序.合并排序. 以下为实现代码: publi ...

  8. Project Management - 3) Manage Your Meetings

    1. 取消没有价值的会议 会议是有代价和成本的 不要举行顺序式的多人进度报告会议 eg: 这周做了什么,下周还要做什么? 除了发言人和项目经理外,每个人都会觉得无聊. 这种会议是在拖项目的后腿,赶紧停 ...

  9. go操作数据库 Go-SQL-Driver/MySQL 使用详解

    go操作mysql的驱动包很多,这里讲解当下比较流行的Go-SQL-Driver/MySQL1.下载安装 执行下面两个命令: 下载:go get github.com/Go-SQL-Driver/My ...

  10. js判断字符在另一个字符串中出现次数

    经过搜索验证,提供两个方法. 1. 通过分割获取长度原理 var s = 'www.51qdq.com';var n = (s.split('.')).length-1;alert(n);  //弹出 ...