老师功能的完善和封装 package jxnd;import java.io.*;import java.util.ArrayList;import java.util.List;import jxnd.Student;import jxnd.Teacher;import jxnd.Tools;public class TeacherManager implements Manager{static List list=new Arra
package jxnd; import java.io.*; import java.util.ArrayList; import java.util.List; import jxnd.Student; import jxnd.Teacher; import jxnd.Tools; public class TeacherManager implements Manager{ static Listlist=new ArrayList (); // static{ // list.add(new Student("1000","卢本伟", "123456", "男", 28, "13037222501","广东")); // list.add(new Student("1001","五五开", "456421", "男", 24, "13012345501","深圳")); // list.add(new Student("1002","提莫", "jie3233", "女", 18, "13037232250","广州")); // list.add(new Student("1003","盖伦", "796444", "男", 28, "13037222501","广东")); // } Teacher tc=new Teacher(); public void login() { int i=0; while (i<3) { if (verification(Tools.getString("请输入账号:"), Tools.getString("请输入密码:"))) { Tools.load(); TeacherMnue(); return; } else { Tools.p("您输入的账号或密码有误!\n您还有"+(3-i-1)+"次重输机会!"); i++; if(Tools.isContinue("是否返回上一层?\t ")){ break; } } } } private void TeacherMnue() { while (true) { Tools.menuFactory("增加学生信息,删除学生信息,查询学生信息,更改学生信息,返回上一层"); switch (Tools.getint("请输入操作选择:")) { case 1: AddStudent(); break; case 2: SelectStuAll(); DeleteStuIndex(); break; case 3: SelectStudentMenu(); break; case 4: UpdateStu(); break; case 5: Tools.save(); return; case 0: Tools.save(); System.exit(0); break; default: break; } } } private void UpdateStu() { while (true) { String msg=Tools.getString("请输入要修改的学生编号:"); for (int i = 0; i < list.size(); i++) { if (list.get(i).getNumber().equals(msg)) { UpdateStuMune(); } } Tools.p("您输入的学生编号有误!"); if(Tools.isContinue("是否返回上一层?\t ")){ break; } } } private void UpdateStuMune() { while (true) { Tools.menuFactory("修改姓名,修改手机号,修改地址"); switch (Tools.getint("请输入选择序列号:")) { case 1: UpdateStuName(); break; case 2: UpdateTelephone(); break; case 3: UpdateSite(); break; case 0: Tools.save(); System.exit(0); break; default: Tools.p("您输入的操作序列号有误!"); break; } if(Tools.isContinue("是否返回上一层?\t ")){ break; } } } private void UpdateSite() { // TODO 自动生成的方法存根 String msg=Tools.getString("请输入要修改的学生编号:"); for (int i = 0; i < list.size(); i++) { if (list.get(i).getNumber().equals(msg)) { list.get(i).setSite((Tools.getString("请输入修改后的地址:"))); } } } private void UpdateTelephone() { // TODO 自动生成的方法存根 String msg=Tools.getString("请输入要修改的学生编号:"); for (int i = 0; i < list.size(); i++) { if (list.get(i).getNumber().equals(msg)) { list.get(i).setTelephone((Tools.getString("请输入修改后的手机号:"))); } else{ Tools.p("修改失败!"); } } } private void UpdateStuName() { // TODO 自动生成的方法存根 String msg=Tools.getString("请输入要修改的学生编号:"); for (int i = 0; i < list.size(); i++) { if (list.get(i).getNumber().equals(msg)) { list.get(i).setName(Tools.getString("请输入修改后的名字:")); } else{ Tools.p("修改失败!"); } } } private void DeleteStuIndex() { while (true) { String msg=Tools.getString("请输入要删除的学生编号:"); for (int i = 0; i < list.size(); i++) { if (list.get(i).getNumber().equals(msg)) { list.remove(i); SelectStuAll(); } } if(!Tools.isContinue("是否返回上一层?\t ")){ break; } } } private void SelectStudentMenu() { while (true) { Tools.menuFactory("查询所有,按编号查询,返回上一层"); switch (Tools.getint("请选择操作序列号:")) { case 1: SelectStuAll(); break; case 2: SelectStunumber(); break; case 3: return; case 0: Tools.save(); System.exit(0); default: break; } } } private void SelectStunumber() { while (true) { String msg=Tools.getString("请输入您要查询的学生编号:"); for (int i = 0; i < list.size(); i++) { if (list.get(i).getNumber().equals(msg)) { System.out.println(list.get(i)); } } Tools.p("找不到您输入学生编号的信息!"); if(Tools.isContinue("是否返回上一层?\t ")){ return; } } } private void SelectStuAll() { for(Object obj:list){ System.out.println(obj); } } private void AddStudent() { list.add(new Student(Tools.getString("请输入添加的编号:"), Tools.getString("请输入添加的姓名:"), Tools.getString("请输入学生密码:"), Tools.getString("请输入学生性别:"), Tools.getint("请输入添加学生年龄:"), Tools.getString("请输入添加学生的手机号码:"), Tools.getString("请输入添加学生的住址:"))); } public boolean verification(String account,String passwod){ if(tc.getName().equals(account)&&tc.getPassword().equals(passwod)) return true; return false; } }