[C/OC的那点事儿]Objective-C实现学生成绩管理系统(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:33 点击:次
p>//
p>
p>#import "StudentSystem.h"
p>
p>@implementation StudentSystem
p>
p>@synthesize studentArray;
p>
p>-(id)init
p>{
p> if (self = [super init]) {
p> studentArray = [[NSMutableArray alloc]init];
p> }
p> else
p> self = nil;
p> return self;
p>
p>}
p>
p>-(void)countStudent
p>{
p> //NSLog(@"一共有 %d 位学生", [[self studentArray] count]);
p> NSLog(@"一共有%lu 位同学",[self.studentArray count]);
p>}
p>
p>
p>-(void)printStudentArray
p>{
p> for (Student *stu in studentArray) {
p> [stu printStudent];
p>
p> }
p> NSLog(@"array 打印完毕.");
p>}
p>
p>-(void)addStudentArray:(Student *)stu
p>{
p>
p> [[self studentArray]addObject:stu];
p> // NSLog(@"添加完成");
p>
p>}
p>
p>-(void)findStudentByStuID
p>{
p> NSLog(@"请输入你要查找的同学的学号:");
p> int studentID;
p> scanf("%d",&studentID);
p>
p> for (Student *stu in studentArray) {
p> if (stu.stuID == studentID) {
p> [stu printStudent];
p> return ;
p> }
p>
p> }
p>
p> NSLog(@"未找到学号为%d的学生.",studentID);
p>
p>}
p>
p>-(void)removeStudentArrayByStuID
p>{
p> NSLog(@"请输入你要删除的同学的学号:");
p> int studentID;
p> scanf("%d",&studentID);
p>
p> for (Student *stu in studentArray) {
p> if (stu.stuID == studentID) {
p> [studentArray removeObject:stu];
p> NSLog(@"删除完成.");
p>
p> return ;
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>