import com.czh.myInterface.AdminInterface;
/**
* 管理员类的信息
* @author GuCe
*2016年3月31日16:42:16
*/
public abstract class Admin implements AdminInterface{
public String adminName;//管理员姓名
public int age;//年龄
public String sex;//性别
public String getAdminName() {
return adminName;
}
public void setAdminName(String adminName) {
this.adminName = adminName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
package com.czh.son;
import java.util.ArrayList;
import java.util.Scanner;
import com.czh.Person.Student;
import com.czh.Person.Teacher;
import com.czh.son.XueSheng;
import com.czh.Person.Admin;
/**
* 这是管理员操作的系统方法
* @author GuCe
*2016年3月31日16:59:25
*/
public class GuanLiYuan extends Admin{
@Override
public void method() {
// TODO Auto-generated method stub
System.out.println("请输入操作:0是查询学生信息,1是添加学生信息,2是修改学生信息,3是删除学生信息,"
+ "\n4是查询教师信息,5是添加教师信息,6是修改教师信息,7是查询学生成绩,8是统计学生成绩,back是返回");
Scanner input =new Scanner(System.in);
String studentName=input.next();
if("0".equals(studentName)){
System.out.println("欢迎进入学生信息查询界面,\n1是查询姓名,\nback是返回上一次");
Scanner input1 =new Scanner(System.in);
String xueSheng=input1.next();
if("1".equals(xueSheng)){
System.out.println("请输入您要查询姓名的学号");
Student stud=new XueSheng();
Scanner newInputID =new Scanner(System.in);
String studentID = newInputID.next();
stud.setId(Integer.parseInt(studentID));
ArrayList<Student> studentList = XueSheng.run();
for(int i=0;i<studentList.size(); ++i)
{
Student stu = studentList.get(i);
int tempID = Integer.parseInt(studentID);
if (tempID == stu.getId())
{
System.out.println("您的学号对应的姓名是:"+stu.getStudentName());
method();
}
}
}
if("back".equals(xueSheng)){
method();
}
}
if("1".equals(studentName)){
System.out.println("已进入添加学生信息界面,1是添加姓名,学号,班级,back是返回上一级");
Scanner input0=new Scanner(System.in);
String student0=input0.next();
if("1".equals(student0)){
System.out.println("您可以添加姓名了");
}else if("back".equals(student0)){
method();
}
Student stud=new XueSheng();
System.out.println("请输入姓名:");
Scanner newInput =new Scanner(System.in);
String studentName2 = newInput.next();
stud.setStudentName(studentName2);
System.out.println("请输入学号:");
Scanner newInputID =new Scanner(System.in);
String studentID = newInputID.next();
stud.setId(Integer.parseInt(studentID));
ArrayList<Student> studentList1 = XueSheng.run();
for(int i=0;i<studentList1.size(); ++i)
{
Student stu = studentList1.get(i);
int tempID = Integer.parseInt(studentID);
if (tempID == stu.getId())
{
System.out.println("已存在学号"+studentID);
method();
}
}
System.out.println("请输入年龄:");
Scanner newInputAge =new Scanner(System.in);
String studentAge = newInputAge.next();
stud.setAge(Integer.parseInt(studentAge));
System.out.println("插入学号"+studentID+"\n姓名:"+ studentName2+ "\n年龄:"+studentAge+"成功!");
Student student4=new XueSheng();
student4.setStudentName(studentName2);
student4.setId(Integer.parseInt(studentID));
student4.setAge(Integer.parseInt(studentAge));
ArrayList<Student>studentList= XueSheng.run();
studentList.add(student4);
method();
}
if("2".equals(studentName)){
System.out.println("已进入修改学生信息界面,请输入要修改学生的学号");
Student stud=new XueSheng();
Scanner newInputID =new Scanner(System.in);
String studentID = newInputID.next();
stud.setId(Integer.parseInt(studentID));
ArrayList<Student> studentList = XueSheng.run();
for(int i=0;i<studentList.size(); ++i)
{
Student stu = studentList.get(i);
int tempID = Integer.parseInt(studentID);
if (tempID == stu.getId())
{
System.out.println("学号正确,您原来的姓名是:"+stu.getStudentName()+"\n请输入您要修改的姓名");
Scanner newInput =new Scanner(System.in);
String studentName2 = newInput.next();
stud.setStudentName(studentName2);
studentList.get(i).setStudentName(studentName2);
System.out.println("修改成功,您的姓名已经变成:"+studentName2);
}
}
method();
}
if("3".equals(studentName)){
System.out.println("已进入删除学生信息界面,1是删除学生或教师,back返回");
Scanner input01 =new Scanner(System.in);
String del01 = input01.next();
if("1".equals(del01)){
System.out.println("已进入删除界面,请输入要删除的学号");
Student stud=new XueSheng();
Scanner newInputID =new Scanner(System.in);
String studentID = newInputID.next();
stud.setId(Integer.parseInt(studentID));
System.out.println("请输入要删除的姓名");
Scanner newInputName =new Scanner(System.in);
String studentName0 = newInputName.next();
stud.setStudentName(studentName0);
ArrayList<Student> studentList1 = XueSheng.run();
for(int i=0;i<studentList1.size(); ++i)
{
Student stu = studentList1.get(i);
int tempID = Integer.parseInt(studentID);
if (tempID == stu.getId()||studentName0.equals(stu.getStudentName()))
{
Student student4=new XueSheng();
student4.setStudentName(studentName0);
student4.setId(Integer.parseInt(studentID));
ArrayList<Student> studentList= XueSheng.run();
studentList.remove(student4);
System.out.println("学号正确,您已经删除的学生:"+stu.getStudentName());
break;
}
}
}
if("back".equals(del01)){
method();
}
method();
}
if("4".equals(studentName)){
System.out.println("已进入教师查询界面,1是查询姓名,back是返回");
Scanner input3 =new Scanner (System.in);
String chaXun=input3.next();
if("1".equals(chaXun)){
System.out.println("请输入您查询教师的工号");
Teacher tea=new JiaoShi();
Scanner teaId=new Scanner (System.in);
String teId=teaId.next();
tea.setId(Integer.parseInt(teId));
ArrayList<Teacher> teacherList=JiaoShi.fun();
for(int i=0;i<teacherList.size();++i){
Teacher teac = teacherList.get(i);
int tempID=Integer.parseInt(teId);
if (tempID == teac.getId())
{
System.out.println("您的工号对应的姓名是:"+teac.getTeacherName());
method();
}
}
}
method();
}
if("5".equals(studentName)){
System.out.println("已进入添加教师信息界面,1是添加教师");
Scanner input1=new Scanner (System.in);
String del=input1.next();
if("1".equals(del)){
System.out.println("请输入您要添加的教师的工号");
Teacher tea=new JiaoShi();
System.out.println("请输入姓名:");
Scanner inputName=new Scanner(System.in);
String teacherName1=inputName.next();
tea.setTeacherName(teacherName1);
System.out.println("请输入工号");
Scanner inputId=new Scanner(System.in);
String teacherId1=inputId.next();
tea.setId(Integer.parseInt(teacherId1));
ArrayList<Teacher>teacherList1=JiaoShi.fun();
for(int i=0;i<teacherList1.size();++i){
Teacher teac = teacherList1.get(i);
int tempID=Integer.parseInt(teacherId1);
if (tempID == teac.getId())
{
System.out.println("已存在此工号");
method();
}
}
System.out.println("插入"+teacherName1+teacherId1+"成功");
Teacher jiaoShi4=new JiaoShi();
jiaoShi4.setTeacherName(teacherName1);
jiaoShi4.setId(Integer.parseInt(teacherId1));
ArrayList<Teacher>teacherList= JiaoShi.fun();
teacherList.add(jiaoShi4);
}
method();
}
if("6".equals(studentName)){
System.out.println("已进入修改教师信息界面,1是修改教师信息");
Scanner input0=new Scanner(System.in);
String input1=input0.next();
if("1".equals(input1)){
System.out.println("请输入您要修改教师的姓名");
Teacher tea=new JiaoShi();
Scanner inputName1=new Scanner(System.in);
String teacherName1=inputName1.next();
tea.setTeacherName(teacherName1);
System.out.println("请输入您要修改教师的工号");
Scanner inputID=new Scanner(System.in);
String teacherId=inputID.next();
tea.setId(Integer.parseInt(teacherId));
ArrayList<Teacher>teacherList=JiaoShi.fun();
for(int i=0;i<teacherList.size();++i){
int tempId=Integer.parseInt(teacherId);
Teacher teac= teacherList.get(i);
if(tempId==teac.getId()){
System.out.println("您输入正确,此时您的工号对应的姓名为:"+teac.getTeacherName()+"\n请输入您要修改的姓名");
Scanner iput=new Scanner(System.in);
String teacherName2=iput.next();
tea.setTeacherName(teacherName2);
teacherList.get(i).setTeacherName(teacherName2);
System.out.println("您的姓名已变成:"+teacherName2);
}
}
}
method();
}
}
@Override
public void inputInformation() {
// TODO Auto-generated method stub
}
@Override
public void queryInformation() {
// TODO Auto-generated method stub
}
}
package com.czh.Person;
/**
* 学生类的信息
* @author GuCe
*2016年3月31日16:33:43
*/
public abstract class Student {
public String studentName;//学生姓名
public String achievement;//成绩
public int id;//学号
public int age;//年龄
public String revert;//返回
public String getRevert() {
return revert;
}
public void setRevert(String revert) {
this.revert = revert;
}
public String sex;//性别
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getAchievement() {
return achievement;
}
public void setAchievement(String achievement) {
this.achievement = achievement;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Override
public boolean equals(Object obj){
if(obj instanceof Student){
Student student =(Student)obj;
if(this.studentName.equals(student.getStudentName())&&this.id==student.getId()){
return true;
}else{
return false;
}
}
return super.equals(obj);
}
@Override
public String toString(){
return (" 学生姓名:"+studentName+" 学号:"+id+" 年龄:"+age+" 性别:"+sex);
}
@Override
public int hashCode(){
return studentName.hashCode()+id;
}
public void xueSheng3() {
// TODO Auto-generated method stub
}
}
package com.czh.son;
import java.util.ArrayList;
import java.util.Scanner;
import com.czh.Person.Student;
public class XueSheng extends Student{
static ArrayList<Student> studentList=new ArrayList<Student>();
public String xueSheng;
public String getXueSheng(){
return xueSheng;
}
public void setXueSheng(String xueSheng){
this.xueSheng =xueSheng;
}
public String xueSheng1;
public String getXueSheng1(){
return xueSheng1;
}
public void setXueSheng1(String xueSheng1){
this.xueSheng1 =xueSheng1;
}
public int xueSheng2;
public int getXueSheng2(){
return xueSheng2;
}
public void setXueSheng2(int xueSheng2){
this. xueSheng2=xueSheng2;
}
public static ArrayList<Student> run(){
Student student=new XueSheng();
student.setStudentName("小白");
student.setId(01);
student.setAge(21);
Student student1=new XueSheng();
student1.setStudentName("小王");
student1.setId(02);
student1.setAge(21);
Student student2=new XueSheng();
student2.setStudentName("秋叶依剑");
student2.setId(03);
student2.setAge(20);
Student student3=new XueSheng();
student3.setStudentName("初一");
student3.setId(04);
student3.setAge(20);
studentList.add(student);
studentList.add(student1);
studentList.add(student2);
studentList.add(student3);
for(int i=0;i<studentList.size();++i){
String tempStudentName=studentList.get(i).getStudentName();
int tempId=studentList.get(i).getId();
int tempAge=studentList.get(i).getAge();
}
return studentList;
}
}
package com.czh.Person;
/**
* 教师类的信息
* @author GuCe
*2016年3月31日16:38:42
*/
public abstract class Teacher {
public String teacherName;//教师姓名
public int id;//年龄
public String sex;//性别
public String getTeacherName() {
return teacherName;
}
public void setTeacherName(String teacherName) {
this.teacherName = teacherName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
package com.czh.son;
import java.util.ArrayList;
import com.czh.Person.Teacher;
public class JiaoShi extends Teacher{
static ArrayList<Teacher> teacherList=new ArrayList<Teacher>();
public static ArrayList<Teacher> fun(){
Teacher jiaoShi=new JiaoShi();
jiaoShi.setTeacherName("张老师");
jiaoShi.setId(101);
Teacher jiaoShi1=new JiaoShi();
jiaoShi1.setTeacherName("鞠老师");
jiaoShi1.setId(102);
Teacher jiaoShi2=new JiaoShi();
jiaoShi2.setTeacherName("于老师");
jiaoShi2.setId(103);
teacherList.add(jiaoShi);
teacherList.add(jiaoShi1);
teacherList.add(jiaoShi2);
for(int i=0;i<teacherList.size();++i){
String tempStudentName1=teacherList.get(i).getTeacherName();
int tempId1=teacherList.get(i).getId();
}
return teacherList;
}
}
package com.czh.myInterface;
/**
* 链接管理员父类与子类之间的桥梁。
* @author GuCe
*2016年3月31日17:00:45
*/
public interface AdminInterface {
public abstract void method();//管理员操作的一个总的概览
public abstract void inputInformation();//录入信息
public abstract void queryInformation();//查询信息
}
package com.czh.myInterface;
public interface StudentInterface {
}
package com.czh.myInterface;
public interface TeacherInterface {
}
package com.czh.main;
import com.czh.son.GuanLiYuan;
public class Main {
public static void main(String[] args){
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("欢迎进入学生管理系统!\n Welcome to the student information management system!");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
GuanLiYuan guanliyuan=new GuanLiYuan();
guanliyuan.method();
}
}