OC学生成绩管理类(三 Student学生类)
2015-11-30 21:01
375 查看
Student.h文件
Student.m文件
// // Student.h // 练习 类 学生成绩管理 // // Created by dllo on 15/11/27. // Copyright © 2015年 dllo. All rights reserved. // #import <Foundation/Foundation.h> #import "Score.h" @interface Student : NSObject { // 特征 NSString *_stuName; NSString *_stuId; NSString *_stuSex; Score *_score; } // 自定义的初始化方法 - (id)initWithName:(NSString *)stuName stuId:(NSString *)stuId sex:(NSString *)sex mathSocre:(CGFloat)mathScore historyScore:(CGFloat)historyScore englishScore:(CGFloat)englishScore; // 自定义的初始化方法2 - (id)initWithName:(NSString *)stuName stuId:(NSString *)stuId sex:(NSString *)sex score:(Score *)score; // 输出当前学生的所有信息 - (void)printInfo; // 设置器和访问器 // name - (void)setName:(NSString *)name; - (NSString *)name; // stuId - (void)setStuId:(NSString *)stuId; - (NSString *)stuId; // sex - (void)setSex:(NSString *)sex; - (NSString *)sex; // score - (void)setScore:(Score *)score; - (Score *)score; @end
Student.m文件
// // Student.m // 练习 类 学生成绩管理 // // Created by dllo on 15/11/27. // Copyright © 2015年 dllo. All rights reserved. // #import "Student.h" @implementation Student // 自定义初始化方法 - (id)initWithName:(NSString *)stuName stuId:(NSString *)stuId sex:(NSString *)sex mathSocre:(CGFloat)mathScore historyScore:(CGFloat)historyScore englishScore:(CGFloat)englishScore{ self = [super init]; if(self){ _stuName = stuName; _stuId = stuId; _stuSex = sex; // 创建Score类的对象 Score *score = [[Score alloc] initWithId:stuId englishScore:englishScore historyScore:historyScore mathScore:mathScore]; _score = score; } return self; } - (id)initWithName:(NSString *)stuName stuId:(NSString *)stuId sex:(NSString *)sex score:(Score *)score{ self = [super init]; if(self){ _stuName = stuName; _stuId = stuId; _stuSex = sex; _score = score; } return self; } // 设置器和访问器 // name - (void)setName:(NSString *)name{ _stuName = name; } - (NSString *)name{ return _stuName; } // stuId - (void)setStuId:(NSString *)stuId{ _stuId = stuId; } - (NSString *)stuId{ return _stuId; } // sex - (void)setSex:(NSString *)sex{ _stuSex = sex; } - (NSString *)sex{ return _stuSex; } // score - (void)setScore:(Score *)score{ _score = score; } - (Score *)score{ return _score; } // 输出当前学生的所有信息 - (void)printInfo{ NSLog(@" %@ %@ %@ Math:%0.2f History:%0.2f English:%0.2f Ave:%0.2f Total:%0.2f", _stuName, _stuId, _stuSex, [_score mathScore], [_score historyScore], [_score englishScore], [_score averageScore], [_score totalScore]); } @end
相关文章推荐
- Autolayout与CATransform3D共同使用引发的问题解决
- ElasticSearch2.0 index中文乱码及解决问题
- 数据结构例程——简单的计数排序
- leetcode 83:Remove Duplicates from Sorted List
- scrollView中嵌套ListView,ListView不能滚动的问题
- WebForms UnobtrusiveValidationMode 需要“jquery”ScriptResourceMapping。请添加一个名为 jquery (区分大小写)的 ScriptResourceMapping。
- ASCII码表16进制版
- 51单片机复习题
- NEUOJ 1660 (容斥+矩阵)
- STL的copy真是是做的了极致的效率
- 1086. Tree Traversals Again
- 学习记录:基于adaboost的人脸检测
- 在Visual Studio中使用VueJS时,不可以用 v-bind 的简写 : 及 v-on的简写 @
- 记一次图片优化经历
- JDBC操作TimesTen
- 欢迎使用CSDN-markdown编辑器
- C语言位运算符:与、或、异或、取反、左移和右移
- 转载AFNetworking源码解析(四)
- ArcGIS AddIn开发之:固定距离+节点生成点
- homerHEVC代码阅读(12)——基础结构之其他结构