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: andWidth:];
[rect printArea];
}
return ;
}
OC3_MyRect的更多相关文章
随机推荐
- Android项目实战--手机卫士24--程序锁的实现以及逻辑
昨天我们已经把程序全部读取出来,显示到界面上了,那今天,我们就来讲一下那个程序锁的实现啦.其实也很简单啦,我们主要就是把用户要锁定的程序放到一个表里面,然后就监听手机里面的任务栈,如果发现任务栈里面出 ...
- JavaScript 要点(十四)HTML DOM 元素(节点)
A.创建新的 HTML 元素 如需向 HTML DOM 添加新元素,必须首先创建该元素(元素节点),然后向一个已存在的元素追加该元素. <div id="div1"> ...
- iOS安全系列之一:HTTPS (轉載)
如何打造一个安全的App?这是每一个移动开发者必须面对的问题.在移动App开发领域,开发工程师对于安全方面的考虑普遍比较欠缺,而由于iOS平台的封闭性,遭遇到的安全问题相比于Android来说要少得多 ...
- java反射快速入门(一)
本文会从以下几个方面讲起 ① 反射的简单解释 ② java反射的API接口 及 demo ③ 反射的优缺点.应用场景 一.什么是反射? java反射:在程序运行中动态获取类的信息,及动态调用对象的方法 ...
- 提高你的Java代码质量吧:如果有必要,使用变长数组吧
一.分析 Java中的数组是定长的,一旦经过初始化声明就不可改变长度,这在实际使用中非常不方便. 二.场景 比如要对班级学生的信息进行统计,因为我们不知道一个班级会有多少学生(随时都有可能会有学生 ...
- [Node.js] Using npm link to use node modules that are "in progress"
It is some times convenient, even necessary, to make use of a module that you are working on before ...
- c++ 怎样获取系统时间
c++ 怎样获取系统时间 2008-04-28 15:34 //方案— 长处:仅使用C标准库:缺点:仅仅能精确到秒级 #include <time.h> #include <stdi ...
- 学习笔记之Linux Shell脚本教程:30分钟玩转Shell脚本编程
Linux Shell脚本教程:30分钟玩转Shell脚本编程 http://c.biancheng.net/cpp/shell/
- C#_Ajax分页MVCPager
UCJqOrderList @model PagedList<Order> <div id="dvOrders"> <table width=&quo ...
- C#_Ajax_分页
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MvcTe ...