本文实例为大家分享了Java实现学生信息管理界面的具体代码,供大家参考,具体内容如下
主类
1
2
3
4
5
6
7
8
9
|
package 学生信息管理系统; public class Main { public static void main(String[] args) { // TODO 自动生成的方法存根 InterFace Menu= new InterFace(); Menu.menu(); } } |
添加信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package 学生信息管理系统; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.Scanner; public class Add { static Stu[] stu= new Stu[ 100 ]; static Scanner scanner= new Scanner(System.in); static int number= 0 ; static InterFace Inter= new InterFace(); public void add() { while ( true ) { try { clear(); } catch (AWTException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } System.out.println( "请输入即将录入的人数:" ); int N=scanner.nextInt(); for ( int i= 0 ;i<N;i++) { stu[number]= new Stu(); System.out.println( "请输入第" +(i+ 1 )+ "个学生的信息:" ); System.out.println( "请输入学号:" ); stu[number].setNum(scanner.next()); System.out.println( "请输入姓名:" ); stu[number].setName(scanner.next()); System.out.println( "请输入性别:" ); stu[number].setSex(scanner.next()); System.out.println( "请输入年龄:" ); stu[number].setAge(scanner.nextInt()); System.out.println( "请输入语文成绩:" ); stu[number].setChinese(scanner.nextFloat()); System.out.println( "请输入数学成绩:" ); stu[number].setMath(scanner.nextFloat()); System.out.println( "请输入英语成绩:" ); stu[number].setEng(scanner.nextFloat()); number++; } System.out.println( "录入完毕,即将返回!" ); Inter.menu(); } } //实现控制台清屏 @SuppressWarnings ( "deprecation" ) public static void clear() throws AWTException { Robot r = new Robot(); r.mousePress(InputEvent.BUTTON3_MASK); // 按下鼠标右键 r.mouseRelease(InputEvent.BUTTON3_MASK); // 释放鼠标右键 r.keyPress(KeyEvent.VK_CONTROL); // 按下Ctrl键 r.keyPress(KeyEvent.VK_R); // 按下R键 r.keyRelease(KeyEvent.VK_R); // 释放R键 r.keyRelease(KeyEvent.VK_CONTROL); // 释放Ctrl键 r.delay( 100 ); } } |
主界面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
package 学生信息管理系统; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.util.*; public class InterFace { static Scanner scanner= new Scanner(System.in); public void menu(){ int select; try { clear(); } catch (AWTException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } do { System.out.println( "\t\t 欢迎使用学生信息管理系统\n" ); System.out.println( "\t\t *** ╭ □═■═□═■═□ ══╮***\n" ); System.out.println( "\t\t * │ 学生信息管理系统 │ *\n" ); System.out.println( "\t\t * ╰═══■═□═■═□═■╯ *\n" ); System.out.println( "\t\t * ┌───────────┐ *\n" ); System.out.println( "\t\t * │1.添加信息 2.加载信息│ *\n" ); System.out.println( "\t\t * │ │ *\n" ); System.out.println( "\t\t * │3.查询信息 4.文件操作│ *\n" ); System.out.println( "\t\t * │ │ *\n" ); System.out.println( "\t\t * │5.数据排序 6.修改信息│ *\n" ); System.out.println( "\t\t * │ │ *\n" ); System.out.println( "\t\t * │7.显示信息 8.删除信息│ *\n" ); System.out.println( "\t\t * │ │ *\n" ); System.out.println( "\t\t * │9.保存信息 0.退出系统│ *\n" ); System.out.println( "\t\t * └───────────┘ *\n" ); System.out.println( "\t\t ************************************\n" ); System.out.println(); System.out.println( "\t请选择操作方式(1~8):\n" ); select=scanner.nextInt(); switch (select){ case 8 : break ; case 5 : break ; case 4 : break ; case 3 : break ; case 2 : break ; case 9 : break ; case 7 : Show show= new Show(); show.show(); break ; case 1 : Add operate= new Add(); operate.add(); break ; case 0 : break ; default : try { clear(); } catch (AWTException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } this .menu(); } } while (select!= 8 ); } @SuppressWarnings ( "deprecation" ) public static void clear() throws AWTException { Robot r = new Robot(); r.mousePress(InputEvent.BUTTON3_MASK); // 按下鼠标右键 r.mouseRelease(InputEvent.BUTTON3_MASK); // 释放鼠标右键 r.keyPress(KeyEvent.VK_CONTROL); // 按下Ctrl键 r.keyPress(KeyEvent.VK_R); // 按下R键 r.keyRelease(KeyEvent.VK_R); // 释放R键 r.keyRelease(KeyEvent.VK_CONTROL); // 释放Ctrl键 r.delay( 100 ); } } |
显示信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package 学生信息管理系统; import java.util.Scanner; public class Show { int n = Add.number; static Scanner scanner= new Scanner(System.in); public void show() { System.out.println( "**********************************************************" ); System.out.println( "学号 姓名 性别 年龄 语文 数学 英语" ); for ( int i = 0 ; i < n; i++) System.out.println(Add.stu[i].getNum() + " " +Add.stu[i].getName()+ " " + Add.stu[i].getSex() + " " + Add.stu[i].getAge() + " " + Add.stu[i].getChinese() + " " + Add.stu[i].getMath() + " " + Add.stu[i].getEng()); System.out.println( "**********************************************************" ); System.out.println(); //n为毫秒数 try { Thread.sleep ( 100000 ) ; } catch (InterruptedException ie){} } } |
学生类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package 学生信息管理系统; public class Stu { private String num; private String name; private String sex; private int age; private float chinese; private float math; private float eng; public String getNum() { return num; } public void setNum(String num) { this .num = num; } public String getName() { return name; } public void setName(String name) { this .name = name; } public String getSex() { return sex; } public void setSex(String sex) { this .sex = sex; } public int getAge() { return age; } public void setAge( int age) { this .age = age; } public float getChinese() { return chinese; } public void setChinese( float chinese) { this .chinese = chinese; } public float getMath() { return math; } public void setMath( float math) { this .math = math; } public float getEng() { return eng; } public void setEng( float eng) { this .eng = eng; } } |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qq_41155209/article/details/80813194