Java实现简单的学生信息管理界面

主类

package 学生信息管理系统;

public class Main {
	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		InterFace Menu=new InterFace();
		Menu.menu();
	}
}

添加信息

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

主界面

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);       
    }
}

显示信息

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){}
	}
}

学生类

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;
	}
}


你可能感兴趣的:(一个菜鸟的Java进阶路)