OC 习题:股票K线计算
发布日期:2021-06-30 22:37:13
浏览次数:3
分类:技术文章
本文共 1084 字,大约阅读时间需要 3 分钟。
一、设计一个K线类
1)最低价格(可读写(get,set))
2)最高价格(可读写(get,set)) 3)平均价格(只读(get) )1、KLine.h
#import@interface KLine : NSObject{ @public float _highPrice; float _lowPrice; float _avgPrice;}-(void)setHighPrice:(float) heighPrice;-(float) getHighPrice;-(void)setLowPrice:(float) lowPrice;-(float) getLowPrice;-(float) getAvgPrice;@end
2、KLine.m
#import "KLine.h"@implementation KLine-(void)setHighPrice:(float) heighPrice{ _highPrice = heighPrice; _avgPrice =(_lowPrice + _highPrice)/2;}-(float) getHighPrice{ return _highPrice;}-(void)setLowPrice:(float) lowPrice{ _lowPrice = lowPrice; _avgPrice =(_lowPrice + _highPrice)/2;}-(float) getLowPrice{ return _lowPrice;}-(float) getAvgPrice{ //return (_lowPrice + _highPrice)/2; return _avgPrice;}@end
3、main.h:
#import#import "KLine.h"int main(int argc, const char * argv[]){ @autoreleasepool { KLine *kline = [KLine new]; [kline setHighPrice:30.0f]; [kline setLowPrice:20.0f]; float avg = [kline getAvgPrice]; NSLog(@"avg = %.2f",avg); } return 0;}
转载地址:https://lovoo.blog.csdn.net/article/details/51484550 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年04月17日 03时19分18秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
xpath定位
2019-05-01
selenium之 如何控制网页内嵌div中滚动条的滚动
2019-05-01
【经验分享】XPATH逻辑运算
2019-05-01
python+selenium 浏览器无界面模式运行
2019-05-01
appium使用过程中的踩坑集
2019-05-01
appium的XPATH获取text值的方式与selenium区别
2019-05-01
处理appium获取toast内容
2019-05-01
解决uiautomatorviewer中添加xpath的方法
2019-05-01
Windows Server R2 安装python时报策略不允许的解决方案
2019-05-01
pip无法安装:换成国内镜像
2019-05-01
python安装mysqlclient[MySQLdb]
2019-05-01
性能测试的必要性评估以及评估方法
2019-05-01
性能测试需求分析
2019-05-01
性能测试需求评审
2019-05-01
性能测试实施流程
2019-05-01
Jmeter在多线程当中对某个http请求进行循环读取配置文件
2019-05-01
Python读取配置文件中文乱码问题
2019-05-01