OC 习题:股票K线计算
发布日期:2021-06-30 22:37:13
浏览次数:2
分类:技术文章
本文共 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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月24日 02时18分48秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
MATLAB与CUDA
2019-04-30
Linux png转jpg (convert命令)
2019-04-30
NAS (Network Attached Storage 网络附属存储)
2019-04-30
Ubuntu更新后终端中字体的颜色全是白色
2019-04-30
vscode git
2019-04-30
基于MATLAB的二进制数字调制与解调信号的仿真——2PSK
2019-04-30
基于MATLAB的模拟调制信号与解调的仿真——DSB
2019-04-30
基于MATLAB的模拟调制信号与解调的仿真——SSB
2019-04-30
HDU - 1166 敌兵布阵 (树状数组模板题/线段树模板题)
2019-04-30
CodeForces - 761C Dasha and Password (思维 暴力)
2019-04-30
POJ - 2481 Cows (树状数组 入门题)
2019-04-30
CodeForces - 987C Three displays (暴力/dp)
2019-04-30
计蒜客 NAIPC 2016 F. Mountain Scenes(dp)
2019-04-30
牛客国庆集训派对Day4——I 连通块计数(思维)
2019-04-30
牛客国庆集训派对Day4——G 区间权值(找规律,双重前缀和)
2019-04-30
牛客国庆集训派对Day5——L 数论之神(找规律/数论)
2019-04-30
CodeForces - 629B Far Relative’s Problem(模拟)
2019-04-30