暑假第三周——学生管理系统仿写

news2024/10/1 19:20:27

iOS学习

  • 前言
  • 账号界面
  • 主页
    • 添加学生信息:
    • 修改学生信息:
    • 删除学生信息:
    • 学生信息排序:
    • 查找学生信息
  • 总结

前言

学生管理系统的仿写较为简单,与c语言的学生管理系统逻辑上相差不大。


账号界面

请添加图片描述

账号界面与3G share的相同,此处不过多介绍。暑期第二周—3G share


主页

请添加图片描述
该页面有四个功能,增删改加上排序。设计思路就是点击按钮时,移除视图上所有按钮,加入相应的文本框和确认返回按钮。


添加学生信息:

效果:
在这里插入图片描述

主体思路就是判断班级是否存在,学生信息是否重复,是否有非法输入。

-(void)press_sure_add:(UIButton*)btn;
{
    if (btn.tag == 101) {
        NSString *str_name = self.tf_name.text;
        NSString *str_goal = self.tf_goal.text;
        NSString *str_class = self.tf_class.text;
        
        int bool1 = 0;
        int bool2 = 0;
        int bool3 = 0;
        
        if (str_goal.integerValue > 100 || str_goal.integerValue < 0) {
            bool3 = 1;
        }
        for (int i = 0; i < _array_name.count; i++) {
            if ([str_name isEqualToString:_array_name[i]] && [str_class isEqualToString:_array_class[i]]) {
                bool1 = 1;
                bool2 = 1;
                break;
            }
        }
        if (![str_class isEqualToString:@"1班"] && ![str_class isEqualToString:@"2班"] && ![str_class isEqualToString:@"3班"]) {
            bool2 = 1;
        }
        if (str_goal.length > 0 && str_name.length > 0 && str_class.length > 0){
            if (bool3 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"添加错误" message:@"成绩超出范围0-100" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else if (bool1 == 1 && bool2 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"添加错误" message:@"该学生已存在" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else if (bool2 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"添加错误" message:@"没有该班级" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else {
                [self.btn_back removeFromSuperview];
                [self.btn_sure removeFromSuperview];
                [self.tf_goal removeFromSuperview];
                [self.tf_class removeFromSuperview];
                [self.tf_name removeFromSuperview];
                [_array_name addObject:str_name];
                [_array_goal addObject:str_goal];
                [_array_class addObject:str_class];
                [self.tableView reloadData];
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"添加成功" message:nil preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
                [self.view addSubview:self.btn_exit];
                [self.view addSubview:self.btn_sort];
                [self.view addSubview:self.btn_add];
                [self.view addSubview:self.btn_serch];
                [self.view addSubview:self.btn_change];
                [self.view addSubview:self.btn_delete];
            }
        } else {
            UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误!" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
            [alertVier addAction:action01];
            [self presentViewController:alertVier animated:YES completion:nil];
        }
    }
}

修改学生信息:

请添加图片描述

此处则是判断信息是否对的上,通过名字班级原成绩来对应一个学生,修改该学生的成绩。

-(void)press_sure_change:(UIButton*)btn
{
    if (btn.tag == 111) {
        NSString *str_name = self.tf_name.text;
        NSString *str_goal = self.tf_goal.text;
        NSString *str_class = self.tf_class.text;
        NSString *str_newGoal = self.tf_newgoal.text;
        
        int bool1 = 0;
        int bool2 = 0;
        int bool3 = 0;
        int bool4 = 0;
        int bool5 = 0;
        
        int bool6 = 0;
        if (str_goal.integerValue > 100 || str_goal.integerValue < 0) {
            bool3 = 1;
        }
        
        if (str_newGoal.integerValue > 100 || str_newGoal.integerValue < 0) {
            bool4 = 1;
        }
        
        for (int i = 0; i < _array_name.count; i++) {
            
            
            if ([str_name isEqualToString:_array_name[i]] && [str_class isEqualToString:_array_class[i]]) {
                bool1 = 0;
                bool2 = 0;
                if (![str_goal isEqual: _array_goal[i]]) {
                    bool5 = 1;
                }
                bool6 = 1;
                break;
            }
            if ([str_name isEqualToString:_array_name[i]] && ![str_class isEqualToString:_array_class[i]]){
                bool1 = 1;
                bool2 = 1;
                bool6 = 1;
            }
        }
        if (![str_class isEqualToString:@"1班"] && ![str_class isEqualToString:@"2班"] && ![str_class isEqualToString:@"3班"]) {
            bool2 = 1;
        }
        
        if (str_goal.length > 0 && str_name.length > 0 && str_class.length > 0 && str_newGoal.length > 0){
            if (bool6 == 0) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"未找到该学生" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            }
            
            if (bool3 == 1 ) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"成绩超出范围0-100" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else if (bool1 == 1 && bool2 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"该学生姓名班级不匹配" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else if (bool2 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"没有该班级" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else if (bool4 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"新成绩超出范围0-100" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            } else if (bool5 == 1) {
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"学生原成绩不匹配" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            }
            else {

                for (int i = 0; i < _array_name.count; i++) {
                    if ([str_name isEqualToString:_array_name[i]] && [str_class isEqualToString:_array_class[i]]){
                        _array_goal[i] = str_newGoal;
                    }
                }
                [self.tableView reloadData];
                
                UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"修改成功" message:nil preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
                [alertVier addAction:action01];
                [self presentViewController:alertVier animated:YES completion:nil];
            }
        } else {
            UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"错误" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
            [alertVier addAction:action01];
            [self presentViewController:alertVier animated:YES completion:nil];
        }
    }
}

删除学生信息:

请添加图片描述
此处则是判断学生名字班级是否匹配,记录位置在数组中删去即可,故不给出代码了。

学生信息排序:

此处排序与C语言相同,可以通过冒泡排序等排序方法实现

-(void)press_sort{
    for (int i = 0 ; i < self.array_name.count - 1; i++) {
        for (int j = i + 1; j < self.array_name.count; j ++) {
            if ([self.array_goal[i] intValue] < [self.array_goal[j] intValue]) {
                id temp = self.array_goal[i];
                self.array_goal[i] = self.array_goal[j];
                self.array_goal[j] = temp;
                
                temp = self.array_class[i];
                self.array_class[i] = self.array_class[j];
                self.array_class[j] = temp;
                
                temp = self.array_name[i];
                self.array_name[i] = self.array_name[j];
                self.array_name[j] = temp;
            }
        }
    }
    
    [self.tableView reloadData];
}

查找学生信息

请添加图片描述
通过学生的姓名查找学生成绩和班级,该管理系允许不同班同名,故会显示所有该名字的学生。可以使用属性传值的方法来实现传入原数组,再将原数组中匹配的加入到查找数组中。

代码实现:

-(void)press_sure
{
    NSString *str_name = self.tf_name.text;
    for (int i = 0; i < self.array_name.count; i ++) {
        if ([str_name isEqualToString:self.array_name[i]]) {
            [self.array_Findgoal addObject:self.array_goal[i]];
            [self.array_Findname addObject:self.array_name[i]];
            [self.array_Findclass addObject:self.array_class[i]];
            self.count_name++;
        }
    }

    if (self.count_name == 0) {
        UIAlertController *alertVier = [UIAlertController alertControllerWithTitle:@"查找失败!" message:@"未查找到该学生" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction* action01 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){/* 在这里编写执行该选项的代码*/}];
        [alertVier addAction:action01];
        [self presentViewController:alertVier animated:YES completion:nil];
    } else {
        self.count_name = 0;
        [self.tableView reloadData];
    }
}


总结

学生管理系统的仿写较为简单,还有难点在于文本框的限制,需要对正则表达式进行学习。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1979536.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

推荐几款卓越的 .NET 开源搜索组件

目录 前言 一、Lucene.NET 1、介绍 2、地址 二、Elasticsearch.NET 和 NEST 1、介绍 2、文档地址 3、开源地址 三、Algolia.Search 1、介绍 2、文档地址 3、开源地址 四、SolrNet 1、介绍 2、文档开源地址 3、Solr社区 五、Masuit.LuceneEFCore.SearchEngine …

网页设计师必备!10个免费的设计素材网站推荐

当网页设计师使用网页设计材料时&#xff0c;他们会优先考虑那些免费和高质量的网页设计材料网站。找到一个免费和高质量的网页设计材料网站并不容易&#xff0c;有些网站要么需要打开材料网站成员&#xff0c;要么设计材料质量很差。即时设计总结了10个免费的网页设计材料网站…

iAppv3无白银会员使用SDK

前言 一个实用小技巧分享给大家。 工具 iapp&#xff1a;百度或点我获取 Mt管理器&#xff1a;百度或点我获取 教程 1.移出“项目路径/apk/lib/”内的全部文件 2.在iapp内测试打包&#xff0c;打包完成后直接返回&#xff0c;不要安装 3.在mt管理器里面点击“项目路径/b…

常见CMS漏洞(WordPress、DeDeCMS、ASPCMS、PHPMyadmin、Pageadmin)

目录 一&#xff1a;WordPress 步骤一:进入Vulhub靶场并执行以下命令开启靶场;在浏览器中访问并安装好子... 步骤二:思路是修改其WP的模板写入一句话木马后门并访问其文件即可GetShel;登陆WP后点击【外观】--》【编辑】 --》 404.php 步骤三:访问以下连接即可获取WebShel...…

【Linux】wsl win安装Linux环境

文章目录 wsl是什么配置wsl启用适用于 Linux 的 Windows 子系统安装 Linux 分发版 文件互操作参考文章 win 下安装linux其实很简单&#xff0c;百度一下wsl就明白了 wsl是什么 WSL&#xff08;Windows Subsystem for Linux&#xff09;是微软开发的一项技术&#xff0c;允许用…

七、分散加载说明

分散加载说明以GD32F103ZE为例&#xff0c;分别用Keil、IAR和Embedded Builder工具实现&#xff1a;将函数放置某个地址、将常量放置某个地址、将函数放在RAM中运行的三种效果。 1、将led_toggle()函数放在0x08040000地址后。 2、将tempbuf[1024]常量放在0x08020000地址后。 …

React管理系统整合Cesium避坑指南

花费了一周时间将React 升级到了最新版本18&#xff0c;同时整合Cesium三维模块到系统中&#xff0c;其中遇到了react 版本升级后模块删改&#xff0c;按照原来的引入方式无法使用的问题&#xff0c;以及Cesium 放入子路由一直404等问题 文章目录 一、系统版本依赖二、系统预览…

3.10.全卷积网络FCN

全连接卷积神经网络&#xff08;FCN&#xff09; ​ FCN是用来深度网络来做语义分割的奠基性工作&#xff0c;用转置卷积层来替换CNN最后的全连接层&#xff0c;从而可以实现对每个像素的预测 ​ CNN(卷积神经网络)可以认为是一个预训练好的模型。CNN的最后一层是全局平均池化…

【C++学习第19天】最小生成树(对应无向图)

一、最小生成树 二、代码 1、Prim算法 #include <cstring> #include <iostream> #include <algorithm>using namespace std;const int N 510, INF 0x3f3f3f3f;int n, m; int g[N][N]; int dist[N]; bool st[N];int prim() {memset(dist, 0x3f, sizeof di…

十大机器学习算法-学习笔记-章节1-线性回归—

一、前言 学习视频&#xff1a;第一章&#xff1a;线性回归原理推导 1-回归问题概述_哔哩哔哩_bilibili 相关资料 该内容仅作为个人笔记使用&#xff0c;希望看到的各位能有所获&#xff0c;博主有误的地方&#xff0c;各位可以在评论区有所指正 二、正文 1、线性回归 什…

CTF-web基础 web服务器

web服务器作用 web服务器是一个服务器软件&#xff0c;我们可以把静态网页部署到web服务器上&#xff0c;web‘服务器通常只能运行静态网页。 应用服务器可以运行动态网页&#xff0c;web服务器通常和应用服务器一起使用。 原理 当我们输入网页时&#xff0c;他会发送请求到…

2024小学生古诗文大会暑期备考:吃透历年真题和知识点(持续)

最近有一些家长朋友问好真题网&#xff0c;上海三年级以上的小学生有什么比较有价值的比赛可以参加&#xff1f;结合众多孩子的反馈和参与情况&#xff0c;好真题网体检参加上海市汉字小达人比赛活动、上海市小学生古诗文大会、AMC8美国数学竞赛等&#xff0c;主要针对的是语文…

使用Python创建多功能文件管理器

简介 在本文中&#xff0c;我们将探索一个使用Python的wxPython库开发的文件管理器应用程序。这个应用程序不仅能够浏览和选择文件&#xff0c;还支持文件预览、压缩、图片转换以及生成PPT演示文稿的功能。 C:\pythoncode\new\filemanager.py 完整代码 import wx import os …

ChatGLM3Loader发生错误Library cudart is not initialized

ChatGLM3Loader执行时发生错误&#xff1a; Library cudart is not initialized。 文章《Chatglm3部署踩坑记录》里提到是因为没有安装 CUDA Toolkit 引起。 1、用 nvidia-smi.exe 命令查看显卡当前驱动程序版本 2、NVIDIA CUDA 工具包发行说明&#xff0c;每个 CUDA 工具包版…

深度学习中常用的激活函数和损失函数

ReLu和Sigmoid的区别。 ReLU在正数区域提供线性响应&#xff0c;有助于加速训练并减少梯度消失问题&#xff0c;而Sigmoid在所有区域都是非线性的&#xff0c;输出范围是0到1&#xff0c;适用于二分类问题&#xff0c;但在深网络中容易造成梯度消失。 Softmax函数的作用。 Soft…

《Advanced RAG》-03-使用 RAGAs + LlamaIndex 进行 RAG 评估

摘要 文章首先介绍了 RAG 评估的三个主要部分&#xff1a;输入查询、检索上下文和 LLM 生成的响应。 提到了 RAGAs 提出的 RAG 评估指标&#xff0c;包括 Faithfulness、Answer Relevance 和 Context Relevance&#xff0c;以及 RAGAs 网站提供的两个额外指标&#xff1a;Conte…

Jenkins未授权访问漏洞 *

漏洞复现 步骤一&#xff1a;使用以下fofa语法进行产品搜索.... port"8080" && app"JENKINS" && title"Dashboard [Jenkins]" 步骤二&#xff1a;在打开的URL中...点击Manage Jenkins --> Scritp Console在执行以下命令..…

JS使用 navigator.clipboard 操作剪切板

注意&#xff1a;需要在安全域下才能够使用&#xff0c;比如&#xff1a;https 协议的地址、127.0.0.1、localhost safari浏览器需要打开配置&#xff0c;在地址栏输入 about:config&#xff0c;搜索 clipboard&#xff0c;将 asyncClipboard 由 false 改为 true&#xff0c;然…

8.3,8.4总结

1.改进渲染 // 加载头像图像InputStream inputStream new ByteArrayInputStream(message.getFileBytes());Image image new Image(inputStream); // 第二个参数表示是否缓存图片&#xff0c;根据需要设置imageView.setImage(image);// 设置头像视图大小imageView.setFitWidth…

安装eclipse时候 打开eclipse出现一连串英文

问题描述&#xff1a;打开eclipse失败&#xff0c;提示错误Version 1.8.xx of the JVM is not suitable for this product Version:11 or greater is required 本地已经有1.8.XX 的jdk&#xff0c;但因为新安装的eclipse需要JVM更高的版本。 原因&#xff1a;jdk版本太低 解…