【JAVA】学生信息管理系统
目錄
前言
一、環境搭建
二、功能實現
1.學生信息類的創建
2.學生信息的添加功能
3.學生信息的刪除功能
4.學生信息的修改功能?
5.學生信息的查看功能
?三、主類的調用
1.界面的搭建
2.學生端和教師端
3.系統和功能的選擇
總結? ? ? ?
前言
JAVA實現的學生信息管理系統(包含教師端和學生端)
教師端有登錄過程,功能包括對學生信息的增刪改查
學生端無登錄過程,功能只包括查看信息
一、環境搭建
二、功能實現
1.學生信息類的創建
? ? ? ?為了防止屬性不能被外類隨意訪問,因此采用private對學生類中的屬性進行修飾并且進行創建set、get方法以便于調用屬性,再創建打印數據方法,方便數據打印,代碼如下:
public class Student {private String id;private String name;private String college;private String major;public Student() {}public Student(String id, String name, String college, String major) {this.id = id;this.name = name;this.college = college;this.major = major;}public String getId() {return id;}public void setId(String id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getCollege() {return college;}public void setCollege(String college) {this.college = college;}public String getMajor() {return major;}public void setMajor(String major) {this.major = major;}public void information_printf() {System.out.printf("%-16s%-13s" + "\t" + "%-12s" + "\t" + "%s\n", getId(), getName(), getCollege(), getMajor());} }2.學生信息的添加功能
? ? ? ?在Addtion添加類中,先創建集合容器用來存放數據,并且鍵盤錄入的數據(使用Scanner()方法),再進行對輸入的判斷是否合法,最后將錄入的數據存入集合中,具體實現方法如下:
public Student Add_information(ArrayList<Student> newList) {Scanner sc = new Scanner(System.in);Student stu = new Student();System.out.println("請輸入學生學號:");//學生學號信息輸入檢查add_check_id(newList, sc, stu);System.out.println("請輸入學生姓名:");String name = sc.next();stu.setName(name);System.out.println("請輸入學生所在學院(4-6字):");//學生學院信息輸入檢查add_check_college(sc, stu);//學生專業班級信息輸入檢查System.out.println("請輸入學生專業班級(4-8字):");add_check_major(sc, stu);return stu;}實現效果如圖:
3.學生信息的刪除功能
? ? ? ?在Delete刪除類中,先創建集合容器用來存放數據,并且鍵盤錄入的數據(使用Scanner()方法),再進行信息的判斷是否存在,最后將需要刪除的信息從集合中刪除,具體實現方法如下:
public ArrayList<Student> Delete_information(ArrayList<Student> newList) {Scanner sc = new Scanner(System.in);System.out.println("請輸入要刪除的學生的學號:");while (true) {String id = sc.next();if (getList_id(newList, id)) {System.out.println("學生信息刪除成功!");break;}System.out.println("該學生信息不存在,請重新輸入:");}return newList;}?實現效果如圖:
4.學生信息的修改功能?
? ? ? ?在Modify修改類中,先創建集合容器用來存放數據,并且鍵盤錄入的數據(使用Scanner()方法),再進行信息的判斷是否存在,再將新錄入的數據代替之前的數據,最后將新的數據重新添加至集合中,具體實現方法如下:
public ArrayList<Student> Modify_information(ArrayList<Student> newList) {Scanner sc = new Scanner(System.in);System.out.println("請輸入要修改的學生的學號:");while (true) {String id = sc.next();if (getList_id(newList, id)) {System.out.println("學生信息修改成功!");break;}System.out.println("該學生信息不存在,請重新輸入:");}return newList;}?實現效果如圖:
5.學生信息的查看功能
? ? ? ?在View查看類中,先創建集合容器用來存放數據,利用for循環對集合遍歷并且調用Student類中的information_printf()方法打印出所有學生信息,具體實現方法如下:
public void View_information(ArrayList<Student> newList) {for (int i = 0; i < newList.size(); i++) {Student s = newList.get(i);s.information_printf();}}?實現效果如圖:
?三、主類的調用
1.界面的搭建
使用System.out.println()方法輸出界面,具體實現方法如下:
//選擇登錄系統界面 System.out.println("----------學生信息管理系統----------"); System.out.println("* 1、學生登錄 2、教師登錄 3、退出 *"); System.out.println("---------------------------------");//學生端界面 System.out.println("----------學生信息管理系統----------"); System.out.println("* 1、查看信息 2、返回 *"); System.out.println("---------------------------------");//教師登錄界面 System.out.println("----------學生信息管理系統----------"); System.out.println("*1、添加信息 2、刪除信息 3、修改信息*"); System.out.println("*4、查看信息 5、返回 *"); System.out.println("---------------------------------");2.學生端和教師端
? ? ? ?學生端只能查看學生信息,教師端可以對信息進行增加、刪除、修改、查看四個功能,并且登錄教師端需要輸入用戶名和密碼;先使用Scanner()方法在控制臺接收用戶鍵盤錄入的數據,再將輸入的數據通過對字符串的判斷實現是否登陸成功。具體實現方法如下:
//教師端登錄 public static void Login_teacher(ArrayList<Student> list) {Scanner sc1 = new Scanner(System.in);Scanner sc2 = new Scanner(System.in);//已知用戶名密碼String name = "Login";String password = "123456";//獲取用戶名密碼while (true) {System.out.println("請輸入用戶名:");String username = sc1.next();System.out.println("請輸入密碼:");String user_password = sc2.next();if (name.equals(username) && password.equals(user_password)) {System.out.println("登陸成功");Management_teacher(list);break;} else {System.out.println("用戶名或密碼錯誤,請重新輸入:");}}}?實現效果如圖:
? ?
3.系統和功能的選擇
? ? ? ?先使用Scanner()方法在控制臺接收用戶鍵盤錄入的數據,再將輸入的數據,通過switch(int flag) case :方法進行判斷選擇對應的系統或對應的功能,具體實現方法如下圖:
//登陸系統選擇 Scanner sc = new Scanner(System.in);wc:while (true) {System.out.println("----------學生信息管理系統----------");System.out.println("* 1、學生登錄 2、教師登錄 3、退出 *");System.out.println("---------------------------------");int flag = sc.nextInt();switch (flag) {case 1:Management_student(list);break;case 2:Login_teacher(list);break;case 3:break wc;default:System.out.println("輸入有誤,請重新輸入:");break;}}//學生功能選擇 Scanner sc = new Scanner(System.in);wc2:while (true) {System.out.println("----------學生信息管理系統----------");System.out.println("* 1、查看信息 2、返回 *");System.out.println("---------------------------------");int flags = sc.nextInt();switch (flags) {case 1:view_Student_information(list);break;case 2:break wc2;}}//教師端功能選擇 Scanner sc = new Scanner(System.in);wc:while (true) {System.out.println("----------學生信息管理系統----------");System.out.println("*1、添加信息 2、刪除信息 3、修改信息*");System.out.println("*4、查看信息 5、返回 *");System.out.println("---------------------------------");int flag = sc.nextInt();switch (flag) {case 1://學生信息的添加add_Student_information(list);break;case 2://學生信息的刪除delete_Student_information(list);break;case 3://學生信息的修改modify_Student_information(list);break;case 4://學生信息的查詢view_Student_information(list);break;case 5:break wc;default:System.out.println("輸入有誤,請重新輸入:");break;}}總結? ? ? ?
? ? ? ?以上就是我實現學生信息管理系統的方案,本文僅僅介紹了實現方案及制作流程,僅供參考,若有問題請幫忙留言指出,歡迎交流學習。
需要所有源文件可以下載
JAVA實現的學生信息管理系統-Java文檔類資源-CSDN文庫https://download.csdn.net/download/huihu__/85208959
總結
以上是生活随笔為你收集整理的【JAVA】学生信息管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: apache配置文件详解与优化
- 下一篇: React开发(197):文件名错误