1. 首页
  2. JAVA

简易Java学生信息管理,无界面化

学生信息类

package ruchu;

public class STxinxi {
	private int student_age;
	private String student_type;
	private String student_number;
	private String student_name;
	public STxinxi(String student_number,String student_name,String student_type,int student_age) {
		super();
		this.student_age= student_age;
		this.student_type = student_type;
		this.student_number = student_number;
		this.student_name = student_name;
	}
	public STxinxi() {
		super();
		// TODO 自动生成的构造函数存根
	}
	public int getStudent_age() {
		return student_age;
	}
	public void setStudent_age(int student_grade) {
		this.student_age = student_grade;
	}
	public String getStudent_type() {
		return student_type;
	}
	public void setStudent_type(String student_type) {
		this.student_type = student_type;
	}
	public String getStudent_number() {
		return student_number;
	}
	public void setStudent_number(String student_number) {
		this.student_number = student_number;
	}
	public String getStudent_name() {
		return student_name;
	}
	public void setStudent_name(String student_name) {
		this.student_name = student_name;
	}
	public String showAll() {
		return (getStudent_number()+" "+getStudent_name()+" "+getStudent_type()+" "+getStudent_age());
	}
	public String getAll() {
		return (getStudent_number()+" "+getStudent_name()+" "+getStudent_type()+" "+getStudent_age()+"\r\n");
	}
}学生操作类
package ruchu;

import java.util.*;
import java.io.*;

public class Student {
	Scanner cin = new Scanner(System.in);
    List<STxinxi>sc=new ArrayList<STxinxi>();
	public void read() throws IOException {
		BufferedReader read = new BufferedReader(new FileReader("D:\\student.txt"));
		String stu=read.readLine();
		while (null!=stu) {
			String[] stu1=stu.split(" ");
			STxinxi sc1=new STxinxi();
			sc1.setStudent_number(stu1[0]);
			sc1.setStudent_name(stu1[1]);
			sc1.setStudent_type(stu1[2]);
			sc1.setStudent_age(Integer.parseInt(stu1[3]));
			sc.add(sc1);
			stu=read.readLine();
		}
		read.close();
	}
	public void add() {
		System.out.println("请输入学号,姓名,年龄,专业");
		String student_id=cin.next();
		String student_name=cin.next();
		int student_age=cin.nextInt();
		String student_type=cin.next();
		STxinxi sc1=new STxinxi();
		sc1.setStudent_age(student_age);
		sc1.setStudent_name(student_name);
		sc1.setStudent_number(student_id);
		sc1.setStudent_type(student_type);
		sc.add(sc1);
	}
	public void show() {
		for (STxinxi sc1:sc) {
			System.out.println(sc1.showAll());
		}
	}
	public void writer() throws IOException {
		FileOutputStream out = new FileOutputStream("D:\\student.txt");
	     for (STxinxi sc1:sc) {
	    	 out.write(sc1.getAll().getBytes());
	     }
	     out.close();
	}
}

 

原创文章,作者:程序员凯小白,如若转载,请注明出处:http://www.kaixiaobai.com/archives/84

发表评论

登录后才能评论

评论列表(2条)

  • 时默 2019年5月26日 下午7:28

    666,大佬牛逼

    • 回复 时默 2019年11月2日 下午6:31

      你是在哪里看到的?

联系我们

qq

在线咨询:点击这里给我发消息

邮件:1298646637@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息