开学后学习Java文件操作,并为了研究main究竟放在那里的问题,又写了一遍学生信息管理系统。这次放弃用Array List,就用了普通的一维数组。顺便整理上来。
1 package Student; 2 3 public class Student 4 { 5 private String stunumber; 6 private String name; 7 private int age; 8 private boolean sex;//man=false,woman=true 9 private Double score;10 Student ()11 {12 stunumber="";13 name="";14 age=0;15 sex=false;16 score=0.0;17 }18 Student (String a,String b,int c,boolean d,Double e)19 {20 stunumber=a;21 name=b;22 age=c;23 sex=d;24 score=e;25 }26 public void set_stunumber(String str)27 {28 stunumber=str;29 }30 public void set_name(String str)31 {32 name=str;33 }34 public void set_age(int n)35 {36 age=n;37 }38 public void set_sex(boolean bool)39 {40 sex=bool;41 }42 public void set_score(Double n)43 {44 score=n;45 }46 public String get_stunumber()47 {48 return stunumber;49 }50 public String get_name()51 {52 return name;53 }54 public int get_age()55 {56 return age;57 }58 public boolean get_sex()59 {60 return sex;61 }62 public Double get_score()63 {64 return score;65 }66 67 }
1 package Student; 2 import java.util.Scanner; 3 import java.io.*; 4 public class StudentManager 5 { 6 private Student stu[]=new Student[100]; 7 private int number; 8 StudentManager() 9 { 10 number=0; 11 12 } 13 public void showStudent() 14 { 15 String s; 16 for(int i=0;i
1 package Student; 2 import java.util.Scanner; 3 public class Main 4 { 5 6 public static void main(String[] args) 7 { 8 Scanner input=new Scanner(System.in); 9 StudentManager m=new StudentManager();10 int select=1;11 for(;;)12 {13 face();14 do15 {16 select=input.nextInt();17 }while(select<1||select>7);18 switch(select)19 {20 case 1:m.showStudent();break;21 case 2:m.addStudent();break;22 case 3:m.deleteStudent();break;23 case 4:m.updateStudent();break;24 case 5:m.selectStudent();break;25 case 6:m.infile();break;26 case 7:m.outfile();break;27 }28 }29 }30 private static void face()31 {32 System.out.println("***************************************************");33 System.out.println(" 石家庄铁道大学信息科学与技术学院");34 System.out.println(" 学生信息管理系统");35 System.out.println("***************************************************");36 System.out.println(" 1.遍历输出学生信息");37 System.out.println(" 2.新学生信息录入");38 System.out.println(" 3.删除学生信息");39 System.out.println(" 4.修改学生信息");40 System.out.println(" 5.查询学生信息");41 System.out.println(" 6.导入文件");42 System.out.println(" 7.导出文件");43 System.out.println("***************************************************");44 }45 }