《经典の学生管理系统》 包括但不限于 高效率的添加 高效率且无漏洞的修改与删除 页面整洁的查看 礼貌的问候功能 为了减少内存根本没用递归, 结合windowbuilder这就是我Java结课设计程序的功能之一了, 目前想好的功能有 学生管理 成绩整理比较和趋势 计算器 课堂随机抽学号 学生量化加分 如果,我是说如果windowbuilder熟练的话可以考虑地图功能,思路就是按行政区分开考验修图技术,再装上监视器,实现点一个省份直接显示百度搜的相关内容 ?
package 学生管理系统;
/**
*
* @author Akina好ぎだ:D
*UJNsk-yyz
*
*/
public class Student {
private String name;
private String age;
private String number;
private String adress;
Student() {
}
public Student(String name, String age, String number, String adress) {
super();
this.name = name;
this.age = age;
this.number = number;
this.adress = adress;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getAdress() {
return adress;
}
public void setAdress(String adress) {
this.adress = adress;
}
public static void main(String[] args) {
}
}
package 学生管理系统;
import java.util.ArrayList;
import java.util.Scanner;
public class StudentManage {
public static void main(String[] args) {
ArrayList<Student> students = new ArrayList<>();
while (true) {
System.out.println("--------欢迎来到学生管理系统--------");
System.out.println("1 添加学生");
System.out.println("2 删除学生");
System.out.println("3 修改学生");
System.out.println("4 查看学生");
System.out.println("5 退出");
System.out.println("请输入你的选择");
Scanner in = new Scanner(System.in);
String a = in.nextLine();
switch (a) {
case "1": {
System.out.println("添加学生");
addStudent(students);
break;
}
case "2": {
System.out.println("删除学生");
deleteStudent(students);
break;
}
case "3": {
System.out.println("修改学生");
changestudent(students);
break;
}
case "4": {
System.out.println("查看学生");
findStudent(students);
break;
}
case "5": {
System.out.println("谢谢您的使用");
System.exit(0);
}
default:
System.out.println("请输入正确序号");
break;
}
}
}
public static void addStudent(ArrayList<Student> student) {
String numberString;
Scanner in1 = new Scanner(System.in);
ArrayList<Student> students = new ArrayList<>();
while (true) {
System.out.println("请输入学号");
numberString = in1.nextLine();
boolean flag = isUsed(students, numberString);
if (flag) {
System.out.println("此学号已被占用");
} else {
break;
}
}
System.out.println("请输入姓名");
String namesString = in1.nextLine();
System.out.println("请输入年龄");
String ageString = in1.nextLine();
System.out.println("请输入地址");
String adressString = in1.nextLine();
Student xStudent = new Student();
xStudent.setAdress(adressString);
xStudent.setAge(ageString);
xStudent.setName(namesString);
xStudent.setNumber(numberString);
student.add(xStudent);
System.out.println("添加学生成功");
}
public static void findStudent(ArrayList<Student> students) {
if (students.size() == 0) {
System.out.println("无信息请添加后查询");
return;
}
System.out.println("学号\t姓名\t年龄\t地址");
for (int i = 0; i < students.size(); i++) {
Student xxStudent = students.get(i);
System.out.println(xxStudent.getNumber() + "\t" + xxStudent.getName() + "\t" + xxStudent.getAge() + "\t"
+ xxStudent.getAdress());
}
}
public static void deleteStudent(ArrayList<Student> students) {
System.out.println("请输入要删除学生的学号");
Scanner in2 = new Scanner(System.in);
String numString = in2.nextLine();
int index = -1;
for (int i = 0; i < students.size(); i++) {
if (students.get(i).getNumber().equals(numString)) {
index = i;
break;
}
}
if (index == -1) {
System.out.println("此学号错误");
} else {
students.remove(index);
System.out.println("删除成功");
}
}
public static void changestudent(ArrayList<Student> students) {
System.out.println("请输入要修改的学生学号");
Scanner in3 = new Scanner(System.in);
String numString = in3.nextLine();
System.out.println("请输入学生新姓名");
String nameString = in3.nextLine();
System.out.println("请输入学生新地址");
String adressString = in3.nextLine();
System.out.println("请输入学生新年龄");
String ageString = in3.nextLine();
Student xStudent = new Student();
xStudent.setNumber(numString);
xStudent.setName(nameString);
xStudent.setAdress(adressString);
xStudent.setAge(ageString);
int index = -1;
for (int i = 0; i < students.size(); i++) {
if (students.get(i).getNumber().equals(numString)) {
index = i;
break;
}
}
if (index == -1) {
System.out.println("此学号错误");
} else {
students.set(index, xStudent);
System.out.println("修改成功");
}
}
public static boolean isUsed(ArrayList<Student> students, String s) {
boolean f = false;
for (int i = 0; i < students.size(); i++) {
if (students.get(i).getNumber().equals(s)) {
f = true;
break;
}
}
return f;
}
}
应该是第二学期末要交上,上一级被退回去太多了,反正基于robocode做基本等于摆烂
仅用于记录
|