java入门项目:学生管理系统(进阶版超详细搭建)

您所在的位置:网站首页 大学生课程管理系统 java入门项目:学生管理系统(进阶版超详细搭建)

java入门项目:学生管理系统(进阶版超详细搭建)

2024-07-13 02:53| 来源: 网络整理| 查看: 265

java入门项目:学生管理系统(进阶版超详细搭建)

[TOC]

1、项目介绍

简介

学生管理系统是一个典型的信息管理系统,熟悉并掌握其需求和设计思想对于理解和学习数据库操作和Java编程有非常大的帮助。

设计思路

思路:分为学生端和教师端

学生端的功能分为登录、注册、查看个人信息、查看成绩、申请修改信息 教师端的功能分为登录、注册、查看学生信息、修改学生信息、删除学生信息、添加学生信息、查看学生申请的修改信息

image-20231014195337098

2、项目搭建

IDEA新建java项目

点击文件 -->新建

image-20231014191547320

点击src右键新建-->软件包

image-20231014191717273

输入软件包名称,回车即可

image-20231014191744591

3、创建实体类

分析

因为实体类可以提供更好的代码组织和数据封装,提高代码的可读性、可维护性和可扩展性,使程序更加健壮和易于开发和维护。

我们有分学生端和教师端,所以我们需要创建两个实体类

Student Teach

学生类和老师类都有自己的属性

学生类

| 信息 | 变量名 | 类型 || :------: | :------: | :----: || 姓名 | Name | String || 学号 | Id | String || 年龄 | Age | int || 性别 | Sex | String || 密码 | Password | String || 家庭住址 | Address | String || 电话 | Phone | String || 语文成绩 | Chinese | double || 数学成绩 | Math | double || 英语成绩 | English | double || 总分 | Score | double |

教师类

| 信息 | 变量名 | 类型 || :--: | :------: | :----: || 姓名 | Name | String || 工号 | Id | String || 年龄 | Age | int || 性别 | Sex | String || 密码 | Password | String || 电话 | Phone | String |

3.1、创建学生类

Student

package com.demo.studentsystem; public class Student { private String Name; //姓名 private String Id; //学号 private int Age; //年龄 private String Sex; //性别 private String Password; //密码 private String Address; //地址 private String Phone; //电话 private double Chinese; //语文成绩 private double Math; //数学成绩 private double English; //英语成绩 private double Score; //总分 public Student() { } public Student(String Name, String Id, int Age, String Sex, String Password, String Address, String Phone, double Chinese, double Math, double English) { this.Name = Name; this.Id = Id; this.Age = Age; this.Sex = Sex; this.Password = Password; this.Address = Address; this.Phone = Phone; this.Chinese = Chinese; this.Math = Math; this.English = English; } /** * 获取 * @return Name */ public String getName() { return Name; } /** * 设置 * @param Name */ public void setName(String Name) { this.Name = Name; } /** * 获取 * @return Id */ public String getId() { return Id; } /** * 设置 * @param Id */ public void setId(String Id) { this.Id = Id; } /** * 获取 * @return Age */ public int getAge() { return Age; } /** * 设置 * @param Age */ public void setAge(int Age) { this.Age = Age; } /** * 获取 * @return Sex */ public String getSex() { return Sex; } /** * 设置 * @param Sex */ public void setSex(String Sex) { this.Sex = Sex; } /** * 获取 * @return Password */ public String getPassword() { return Password; } /** * 设置 * @param Password */ public void setPassword(String Password) { this.Password = Password; } /** * 获取 * @return Address */ public String getAddress() { return Address; } /** * 设置 * @param Address */ public void setAddress(String Address) { this.Address = Address; } /** * 获取 * @return Phone */ public String getPhone() { return Phone; } /** * 设置 * @param Phone */ public void setPhone(String Phone) { this.Phone = Phone; } /** * 获取 * @return Chinese */ public double getChinese() { return Chinese; } /** * 设置 * @param Chinese */ public void setChinese(double Chinese) { this.Chinese = Chinese; } /** * 获取 * @return Math */ public double getMath() { return Math; } /** * 设置 * @param Math */ public void setMath(double Math) { this.Math = Math; } /** * 获取 * @return English */ public double getEnglish() { return English; } /** * 设置 * @param English */ public void setEnglish(double English) { this.English = English; } /** * 获取 * @return Score */ public double getScore() { this.Score = (this.Math+this.English+this.Chinese) / 3; return this.Score; } public String toString() { return "Student{Name = " + Name + ", Id = " + Id + ", Age = " + Age + ", Sex = " + Sex + ", Password = " + Password + ", Address = " + Address + ", Phone = " + Phone + ", Chinese = " + Chinese + ", Math = " + Math + ", English = " + English + ", Score = " + Score + "}"; } public void viewPerson(){ System.out.println("姓名:"+getName()); System.out.println("年龄:"+getAge()); System.out.println("学号:"+getId()); System.out.println("性别:"+getSex()); System.out.println("密码:"+getPassword()); System.out.println("住址:"+getAddress()); System.out.println("电话:"+getPhone()); } public void viewAchieve(){ System.out.println("语文成绩:"+getChinese()); System.out.println("数学成绩:"+getMath()); System.out.println("英语成绩:"+getEnglish()); System.out.println("总分:"+getScore()); } } 3.2、创建教师类

Teach

package com.demo.studentsystem; public class Teach { private String name; private String Id; private int Age; private String Sex; private String Password; private String Phone; public Teach() { } public Teach(String name, String Id, int Age, String Sex, String Password, String Phone) { this.name = name; this.Id = Id; this.Age = Age; this.Sex = Sex; this.Password = Password; this.Phone = Phone; } /** * 获取 * @return name */ public String getName() { return name; } /** * 设置 * @param name */ public void setName(String name) { this.name = name; } /** * 获取 * @return Id */ public String getId() { return Id; } /** * 设置 * @param Id */ public void setId(String Id) { this.Id = Id; } /** * 获取 * @return Age */ public int getAge() { return Age; } /** * 设置 * @param Age */ public void setAge(int Age) { this.Age = Age; } /** * 获取 * @return Sex */ public String getSex() { return Sex; } /** * 设置 * @param Sex */ public void setSex(String Sex) { this.Sex = Sex; } /** * 获取 * @return Password */ public String getPassword() { return Password; } /** * 设置 * @param Password */ public void setPassword(String Password) { this.Password = Password; } /** * 获取 * @return Phone */ public String getPhone() { return Phone; } /** * 设置 * @param Phone */ public void setPhone(String Phone) { this.Phone = Phone; } public String toString() { return "Teach{name = " + name + ", Id = " + Id + ", Age = " + Age + ", Sex = " + Sex + ", Password = " + Password + ", Phone = " + Phone + "}"; } } 4、功能实现

分析

首先我们需要先搭建起来登录界面,登录界面应该包含登录、注册功能 登录注册需要填写身份,判断是学生还是教师,再选择进入对应的界面

创建main函数

接下来的实现都是在主函数里面创建了,自行创建main函数

public class SystemDemo { public static void main(String[] args) { } } 4.1、编写主界面 /** * 主界面搭建 */ while (true) { System.out.println("_________________________________"); System.out.println(" 欢迎使用学生管理系统 "); System.out.println(" 1、登录系统 "); System.out.println(" 2、注册账号" ); System.out.println(" 3、退出系统" ); System.out.println("_________________________________"); //从键盘接受数据 System.out.println("请输入您的选择:"); Scanner scanner = new Scanner(System.in); int Number = scanner.nextInt(); if (Number == 1){ //调用登录界面 LoginSystem(); } else if (Number == 2){ //调用注册界面 RegisterSystem(); } else if (Number == 3){ System.out.println("感谢您的使用系统"); //调出循环 break; } else { System.out.println("输入错误,请选择序号里面的数字"); } } 4.2、编写登录界面

分析

登录界面需要验证身份,选择让进入学生端还是教师端 //登录界面 public static void LoginSystem() { System.out.println("欢迎进入登录界面"); Scanner scanner = new Scanner(System.in); while (true){ System.out.println("请输入您的身份(教师或者学生,输入0则返回上一级):"); String identity = scanner.next(); if ("教师".equals(identity)){ System.out.println("请输入您的工号:"); String id = scanner.next(); System.out.println("请输入您的密码"); String password = scanner.next(); //调用判断是否存在 boolean result = JudgmentExistTeach(id, password); if (result){ System.out.println("登录成功"); //跳转到教师端 TeachTerminal(id); } else { System.out.println("登录失败,请检查你的工号和密码是否有问题"); } } else if ("学生".equals(identity)){ System.out.println("请输入您的学号:"); String id = scanner.next(); System.out.println("请输入您的密码"); String password = scanner.next(); //调用判断是否存在 boolean result = JudgmentExistStudent(id, password); if (result){ System.out.println("登录成功"); //跳转到学生 StudentTerminal(id); } else { System.out.println("登录失败,请检查你的工号和密码是否有问题"); } } else { if (identity.equals("0")){ break; } System.out.println("您的输入有问题"); } } }

创建方法判断教师是否存在

通过传进来的id和password和集合进行判断,id存在,password正确说明登录成功

public static boolean JudgmentExist(String id,String password){ //如果列表里面没有东西,那就不需要判断,直接返回不存在 if (ArrayTeach.size() == 0){ System.out.println("用户不存在,请注册"); return false; } //循环判断用户是否存在 for (int i = 0; i


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3