OC学生成绩管理类(一 综述)

        刚学习了OC两天,用面向对象的思想编写了一个学生成绩管理类来复习总结一下.文件一共有三个类,分别是Classroom教室类,Student学生类和Score分数类.下面详细介绍每一个类.因为当时没有学到属性,所以使用的是成员变量

 Classroom教室类

       保存每个学生的信息,教室的名称,教师姓名等基本信息.

      具有添加学生,按分数排名输出学生信息,输出有不及格成绩的学生信息,输出低于平均分的学生信息,显示班级平均分的方法;

 Student学生类

      保存一个学生的姓名,性别,学号和分数

      有输出当前学生的信息的方法.

Score分数

      保存各科成绩

      具有设置和返回成绩的方法.

下面是main函数,接下来的三个博客会有其他三个类的源代码.

//
//  main.m
//  练习 类 学生成绩管理
//
//  Created by dllo on 15/11/27.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Student.h"
#import "Classroom.h"
int main(int argc, const char * argv[]) {
    // 声明七个学生对象
    Student *stu1 = [[Student alloc] initWithName:@"张三" stuId:@"0001" sex:@"男" mathSocre:60 historyScore:50 englishScore:65];
    Student *stu2 = [[Student alloc] initWithName:@"李四" stuId:@"0002" sex:@"男" mathSocre:89 historyScore:70 englishScore:65];
    Student *stu3 = [[Student alloc] initWithName:@"王五" stuId:@"0003" sex:@"女" mathSocre:89 historyScore:80 englishScore:85];
    Student *stu4 = [[Student alloc] initWithName:@"田六" stuId:@"0004" sex:@"女" mathSocre:89 historyScore:70 englishScore:75];
    Student *stu5 = [[Student alloc] initWithName:@"年七" stuId:@"0005" sex:@"男" mathSocre:80 historyScore:60 englishScore:65];
    Student *stu6 = [[Student alloc] initWithName:@"沙八" stuId:@"0006" sex:@"女" mathSocre:60 historyScore:65 englishScore:65];
    Student *stu7 = [[Student alloc] initWithName:@"失九" stuId:@"0007" sex:@"男" mathSocre:50 historyScore:60 englishScore:65];
    
    // 声明一个教室对象
    Classroom *classroom = [[Classroom alloc] initWithName:@"一班"];
    // 将学生对象添加到教室对象中
    [classroom addStudent:stu1];
    [classroom addStudent:stu2];
    [classroom addStudent:stu3];
    [classroom addStudent:stu4];
    [classroom addStudent:stu5];
    [classroom addStudent:stu6];
    [classroom addStudent:stu7];
    // 按学号输出所有的学生信息
    [classroom printAllStudentInfo];
    // 按分数降序输出所有信息
    [classroom printAllStudentInfoByDescending];
    // 输出有没及格的课的学生信息
    [classroom printFailStudent];
    // 按学号输出所有的学生信息
    [classroom printAllStudentInfo];
    // 输出成绩在班级平均分以下的同学
    [classroom printStudentScoreUnderAverage];
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值