赞
踩
用户类
import java.util.Scanner;
public class Stu_System {
static boolean bool=true;
static Student[] students = new Student[2000];
//主函数
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(bool) {
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("**** 6:退出 ****");
System.out.println("**** 请输入你要进行的操作(1-6) ****");
if (!sc.hasNextInt()) {
System.out.println("请输入数字\n");
} else {
int flag = sc.nextInt();
switch (flag) {
case 1:
addstu();
break;
case 2:
inquirestu();
break;
case 3:
changestu();
break;
case 4:
deletestu();
break;
case 5:
printstu();
break;
case 6:
bool = false;
break;
default:System.out.println("请输入1-6");
break;
}
}
}
sc.close();
System.out.println("系统关闭");
}
//打印学生信息
private static void printstu() {
for (Student student : students) {
if(student!=null)
System.out.println(student);
}
System.out.println();
}
//删除学生信息
private static void deletestu() {
Scanner sc = new Scanner(System.in);
System.out.println("删除的学生学号:");
if(!sc.hasNextInt())
{
System.out.println("未输入学号");
bool = false;
}else {
int ID = sc.nextInt();
for(int i = 0;i
student类:
public class Student {
private int ID;
private String name;
private String clas;
public Student(int num,String name,String clas)
{
ID = num;
this.name = name;
this.clas = clas;
}
public String getName() {
return name;
}
public String getClas() {
return clas;
}
public void setID(int ID) {
this.ID = ID;
}
public void setName(String name) {
this.name = name;
}
public void setClas(String clas) {
this.clas = clas;
}
public int getID() {
return ID;
}
@Override
public String toString() {
return "Student{" +
"ID=" + ID +
", name='" + name + '\'' +
", clas='" + clas + '\'' +
'}';
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。