求教一个赋值问题
xcode吧
全部回复
仅看楼主
level 6
zhy82979261 楼主
2012年12月12日 04点12分 1
level 6
zhy82979261 楼主

#import <Foundation/Foundation.h>
@interface XYPoint :
NSObject
{
float x;
float y;
}
@property
(nonatomic
,assign
) float
x;
@property
(nonatomic
,assign
) float
y;
-(
id)initWith_x_y:(
float)a :(
float)b;
-(
void)printPoint_x_y;
@end 
2012年12月12日 04点12分 2
level 6
zhy82979261 楼主

#import <Foundation/Foundation.h>
#import "XYPoint.h"
@interface Rectangle :
NSObject
{
float wide;
float high;
XYPoint *origin,*a,*b,*c;
}
@property
(nonatomic
,assign
) float
wide;
@property
(nonatomic
,assign
) float
high;
@property
(nonatomic
,retain
)
XYPoint
* origin;
@property
(nonatomic
,retain
)
XYPoint
* a;
@property
(nonatomic
,retain
)
XYPoint
* b;
@property
(nonatomic
,retain
)
XYPoint
* c;
-(
id)translate:(
Rectangle*)rec :(
float)a :(
float) b;
-(
void)setvalues:(
XYPoint*)p1 :(
XYPoint*)p2 :(
XYPoint*)p3 :(
XYPoint*)p4;
-(
bool)ifRectangle:(
XYPoint*)p1 :(
XYPoint*)p2 :(
XYPoint*)p3 :(
XYPoint*)p4;
-(
bool)ifTranslate:(
int)a;
-(
void)printWide;
-(
void)printHige;
-(
void)printPerimeter;
-(
void)printArea;
@end 
2012年12月12日 04点12分 3
level 6
zhy82979261 楼主

#import "Rectangle.h"
@implementation
Rectangle
@synthesize wide,high,origin,a,b,c;
-(
void)setvalues:(
XYPoint*)p1 :(
XYPoint*)p2 :(
XYPoint*)p3 :(
XYPoint*)p4
{

NSLog
(@"
从原点开始,逆时针输入4
个坐标值!\n"
);
BOOL ifcontinue =
1;
Rectangle *rec1 = [[
Rectangle
alloc]
init];
while (ifcontinue)
{
ifcontinue = [rec1
ifRectangle:p1 :p2 :p3 :p4];
if (ifcontinue)
{
origin = p1;
a = p2;
b = p3;
c = p4;
wide =
}
}
}
-(
bool)ifRectangle:(
XYPoint*)p1 :(
XYPoint*)p2 :(
XYPoint*)p3 :(
XYPoint*)p4
{
if(p1.
y == p2.
y && p2.
x ==p3.
x &&p3.
y == p4.
y && p4.
x == p1.
x)
{
return
1;

NSLog
(@"
图像为矩形,继续..........\n"
);
}
else
{

NSLog
(@"
图形不为矩形请重新输入坐标:"
);
return
0;
}
}
2012年12月12日 04点12分 4
level 6
zhy82979261 楼主
在setValues函数里 我要实现wide = p2.x-p1.x这个赋值 该怎么写
2012年12月12日 04点12分 5
没明白难点何在。。。如果不能直接使用.来访问对象内的属性,就用[]下标索引- -
2013年02月18日 08点02分
level 2
求发一份你的xcode和sdk 万分感谢 或者下载的链接也可以 [email protected]
2012年12月16日 05点12分 6
你要Xcode的下载地址?
2012年12月17日 07点12分
回复 zhy82979261 :2个我都发你了
2012年12月17日 07点12分
level 12
不好意思 我还在学c++阶段,用xcode的环境。但是还没学到哪里 我也不知道怎么办。。面向对象还没教呢
2012年12月24日 12点12分 7
level 3
看了一下就不想看了.发源码吧。[气愤]
2012年12月31日 02点12分 8
level 2
我也想要一份Xcode的下载地址 可以发给我吗 [email protected]谢谢
2013年02月10日 13点02分 9
1