[C/OC的那点事儿]Objective-C实现学生成绩管理系统(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:33 点击:次
p>{
p> NSLog(@"学号%d,姓名:%@,年龄:%d,成绩: %d",self.stuID,self.name,self.age,self.score);
p>
p> // NSLog(@"打印完成.");
p>
p>}
p>
p>-(void)encodeWithCoder:(NSCoder *)aCoder
p>{
p> [aCoder encodeInt:stuID forKey:@"id"];
p> [aCoder encodeObject:name forKey:@"name"];
p> [aCoder encodeInt:age forKey:@"age"];
p> [aCoder encodeInt:score forKey:@"score"];
p>
p>
p>}
p>
p>-(id)initWithCoder:(NSCoder *)aDecoder
p>{
p> if (self = [super init]) {
p> self.stuID = [aDecoder decodeIntForKey:@"id"];
p> self.name = [aDecoder decodeObjectForKey:@"name"];
p> self.age = [aDecoder decodeIntForKey:@"age"];
p> self.score = [aDecoder decodeIntForKey:@"score"];
p> }
p> return self;
p>
p>}
p>
p>
p>
p>
p>@end
p>系统数组的实现:
p>[objc]
p>//
p>// StudentSystem.h
p>// OC实现学生成绩管理系统
p>//
p>// Created by lichan on 13-11-28.
p>// Copyright (c) 2013年 com.lichan. All rights reserved.
p>//
p>
p>#import <Foundation/Foundation.h>
p>
p>#import "Student.h"
p>
p>@interface StudentSystem : NSObject
p>
p>
p>
p>@property NSMutableArray *studentArray;
p>
p>
p>-(id)init;
p>
p>-(void)printStudentArray;
p>
p>-(void)addStudentArray:(Student *)stu;
p>
p>-(void)findStudentByStuID;
p>
p>-(void)removeStudentArrayByStuID;
p>
p>
p>
p>-(void)writeToFile;
p>
p>-(void)readFromFile;
p>
p>-(void)countStudent;
p>
p>-(void)SortStudentArray;// >0升序,<0降序
p>
p>-(void)motifyStudent;
p>
p>
p>@end
p>
p>.m文件
p>[objc]
p>//
p>// StudentSystem.m
p>// OC实现学生成绩管理系统
p>//
p>// Created by lichan on 13-11-28.
p>// Copyright (c) 2013年 com.lichan. All rights reserved.
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>