[C/OC的那点事儿]Objective-C实现学生成绩管理系统
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:33 点击:次
[objc]
p>[objc]
p>//
p>// Student.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>@interface Student : NSObject<NSCoding>
p>{
p>@protected
p> int stuID;
p> NSString * name;
p> int age;
p> int score;
p>
p>}
p>
p>
p>
p>@property int stuID;
p>@property NSString * name;
p>@property int age;
p>@property int score;
p>
p>-(id)init;
p>-(void)inputStudent;
p>-(void)printStudent;
p>
p>//-(void)modifyStudent;
p>
p>
p>
p>
p>@end
p>
p>Student.m文件
p>
p>[objc]
p>//
p>// Student.m
p>// OC实现学生成绩管理系统
p>//
p>// Created by lichan on 13-11-28.
p>// Copyright (c) 2013年 com.lichan. All rights reserved.
p>//
p>
p>#import "Student.h"
p>
p>static int staticID = 1;
p>
p>@implementation Student
p>
p>@synthesize stuID,name,age,score;
p>
p>-(id)init
p>{
p> if (self = [super init]) {
p> stuID = staticID;
p> staticID++;
p> name = nil;
p> age = 0;
p> score = 0;
p> }
p> else
p> {
p> self = nil;
p> }
p> return self;
p>
p>}
p>-(void)inputStudent
p>{
p> NSLog(@"请输入学号为%d的姓名,年龄,成绩(格式ag:lichan 18 100)",stuID);
p> char CharName[20];
p> int intAge,intScore;
p> scanf("%s %d %d",CharName,&intAge,&intScore);
p>
p> [self setName:[[NSString alloc]initWithUTF8String:CharName]];
p> [self setAge:intAge];
p> [self setScore:intScore];
p>
p> // NSLog(@"录入完成!");
p>
p>
p>}
p>-(void)printStudent
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>