最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java實(shí)現(xiàn)簡(jiǎn)單的學(xué)生教師管理系統(tǒng)

 更新時(shí)間:2022年02月25日 07:28:41   作者:初學(xué)Java的萌新  
這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)簡(jiǎn)單的學(xué)生教師管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Java實(shí)現(xiàn)學(xué)生教師管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

需求:

我們可以通過管理系統(tǒng)對(duì)學(xué)生和教師進(jìn)行管理
對(duì)象學(xué)生和教師進(jìn)行增刪改查等的功能

1、Student和Teacher的父類
2、Student類
3、Teacher類
4、Utils工具類
5、測(cè)試類

Student和Teacher的父類

public class Person {
? ? private String id; // 編號(hào)
? ? private String name; // 姓名
? ? private String IDcard; // 身份證
? ? private String sex; // 性別
? ? private String birthday; // 生日
? ? private int age; //年齡
? ? private String site; //地址
? ? private String phone; // 電話

? ? public Person() {
? ? }

? ? public Person(String id, String name, String IDcard, String sex, String birthday, String site, String phone) throws ParseException {
? ? ? ? this.id = id;
? ? ? ? this.name = name;
? ? ? ? this.IDcard = IDcard;
? ? ? ? this.sex = sex;
? ? ? ? this.birthday = birthday;
? ? ? ? this.age = Utils.birthdayToAge(birthday);
? ? ? ? this.site = site;
? ? ? ? this.phone = phone;
? ? }

? ? public String getId() {
? ? ? ? return id;
? ? }

? ? public void setId(String id) {
? ? ? ? this.id = id;
? ? }

? ? public String getName() {
? ? ? ? return name;
? ? }

? ? public void setName(String name) {
? ? ? ? this.name = name;
? ? }

? ? public String getIDcard() {
? ? ? ? return IDcard;
? ? }

? ? public void setIDcard(String IDcard) {
? ? ? ? this.IDcard = IDcard;
? ? }

? ? public String getSex() {
? ? ? ? return sex;
? ? }

? ? public void setSex(String sex) {
? ? ? ? this.sex = sex;
? ? }

? ? public String getBirthday() {
? ? ? ? return birthday;
? ? }

? ? public void setBirthday(String birthday) throws ParseException {
? ? ? ? this.birthday = birthday;
? ? ? ? this.age = Utils.birthdayToAge(birthday);
? ? }

? ? public int getAge() {
? ? ? ? return age;
? ? }

? ? public String getSite() {
? ? ? ? return site;
? ? }

? ? public void setSite(String site) {
? ? ? ? this.site = site;
? ? }

? ? public String getPhone() {
? ? ? ? return phone;
? ? }

? ? public void setPhone(String phone) {
? ? ? ? this.phone = phone;
? ? }
}

Student類

import java.text.ParseException;

public class Student extends Person {
? ? private int grade; // 成績(jī)
? ? private String group; // 班級(jí)

? ? // 學(xué)生號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),成績(jī),班級(jí)
? ? public Student(String id, String name, String IDcard, String sex, String birthday, String site, String phone, int grade, String group) throws ParseException {
? ? ? ? super(id, name, IDcard, sex, birthday, site, phone);
? ? ? ? this.grade = grade;
? ? ? ? this.group = group;
? ? }

? ? public Student() {
? ? }

? ? public int getGrade() {
? ? ? ? return grade;
? ? }

? ? public void setGrade(int grade) {
? ? ? ? this.grade = grade;
? ? }

? ? public String getGroup() {
? ? ? ? return group;
? ? }

? ? public void setGroup(String group) {
? ? ? ? this.group = group;
? ? }
}

Teacher類

import java.text.ParseException;

public class Teacher extends Person{
? ? private String career; // 專業(yè)
? ? private String salary; // 工資
? ? // 教師號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),專業(yè),工資
? ? public Teacher(String id, String name, String IDcard, String sex, String birthday, String site, String phone, String career, String salary) throws ParseException {
? ? ? ? super(id, name, IDcard, sex, birthday, site, phone);
? ? ? ? this.career = career;
? ? ? ? this.salary = salary;
? ? }

? ? public Teacher() {
? ? }

? ? public String getCareer() {
? ? ? ? return career;
? ? }

? ? public void setCareer(String career) {
? ? ? ? this.career = career;
? ? }

? ? public String getSalary() {
? ? ? ? return salary;
? ? }

? ? public void setSalary(String salary) {
? ? ? ? this.salary = salary;
? ? }
}

根據(jù)生日計(jì)算年齡的一個(gè)靜態(tài)工具類

Utils

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Utils {
? ? public static int birthdayToAge(String birthday) throws ParseException {

? ? ? ? SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
? ? ? ? Date date = sdf.parse(birthday);
? ? ? ? Date date1 = new Date();
? ? ? ? long time = date.getTime();
? ? ? ? long time1 = date1.getTime();
? ? ? ? long age = (time1 - time) / 1000 / 60 / 60/ 24 / 365;
? ? ? ? return (int)age;
? ? }
}

測(cè)試類

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Scanner;

public class StudentAndTeacherSystem {
? ? public static Scanner sc = new Scanner(System.in);
? ? public static ArrayList<Student> students = new ArrayList();
? ? public static ArrayList<Teacher> teachers = new ArrayList();
? ? public static void main(String[] args) throws ParseException {
? ? ? ? System.out.println("********************歡迎來到學(xué)生教師管理系統(tǒng)********************");
? ? ? ? while (true) {
? ? ? ? ? ? System.out.println("【1】 學(xué)生管理系統(tǒng) ? ? ?【2】 教師管理系統(tǒng) ? ? ?【3】 退出");

? ? ? ? ? ? String num = sc.next();
? ? ? ? ? ? switch (num) {
? ? ? ? ? ? ? ? case "1":
? ? ? ? ? ? ? ? ? ? // 學(xué)生管理系統(tǒng)
? ? ? ? ? ? ? ? ? ? studentSystem();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "2":
? ? ? ? ? ? ? ? ? ? // 教師管理系統(tǒng)
? ? ? ? ? ? ? ? ? ? teacherSystem();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "3":
? ? ? ? ? ? ? ? ? ? System.out.println("感謝您的使用!");
? ? ? ? ? ? ? ? ? ? System.exit(0);
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的編號(hào)" + num + "有誤!");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? // 學(xué)生
? ? public static void studentSystem() throws ParseException {

? ? ? ? System.out.println("**********************【歡迎來到學(xué)生管理系統(tǒng)】**********************");
? ? ? ? while (true){
? ? ? ? ? ? System.out.println("*******【1】添加學(xué)生***************************【2】 修改學(xué)生*********");
? ? ? ? ? ? System.out.println("*******【3】刪除學(xué)生***************************【4】 查看所有學(xué)生******");
? ? ? ? ? ? System.out.println("*******【5】查找指定學(xué)生************************【6】 統(tǒng)計(jì)所有學(xué)生信息**");
? ? ? ? ? ? System.out.println("***************************【7】 返回上一級(jí)***************************");
? ? ? ? ? ? System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~【請(qǐng)輸入您要選擇的編號(hào)】~~~~~~~~~~~~~~~~~~~~~~~~");
? ? ? ? ? ? String num = sc.next();
? ? ? ? ? ? switch (num){
? ? ? ? ? ? ? ? case "1":
? ? ? ? ? ? ? ? ? ? // 添加
? ? ? ? ? ? ? ? ? ? addStudent();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "2":
? ? ? ? ? ? ? ? ? ? // 修改
? ? ? ? ? ? ? ? ? ? updateStudent();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "3":
? ? ? ? ? ? ? ? ? ? // 刪除
? ? ? ? ? ? ? ? ? ? deleteStudent();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "4":
? ? ? ? ? ? ? ? ? ? // 查看
? ? ? ? ? ? ? ? ? ? selectStudent();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "5":
? ? ? ? ? ? ? ? ? ? // 指定查看
? ? ? ? ? ? ? ? ? ? assignStudent();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "6":
? ? ? ? ? ? ? ? ? ? // 統(tǒng)計(jì)
? ? ? ? ? ? ? ? ? ? statisticsStudent();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "7":
? ? ? ? ? ? ? ? ? ? System.out.println("返回上一級(jí)");
? ? ? ? ? ? ? ? ? ? return;
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的編號(hào)" + num + "有誤!");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }

? ? ? ? }

? ? }
? ? public static void addStudent() throws ParseException {
// ? ? ? ?System.out.println("添加成功!");
? ? ? ? System.out.println("請(qǐng)輸入您的學(xué)生號(hào):");
? ? ? ? while (true) {
? ? ? ? ? ? String id = sc.next();
? ? ? ? ? ? int index = getIndex(students, id);
? ? ? ? ? ? if (index == -1) {
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的姓名:");
? ? ? ? ? ? ? ? String name = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的身份證:");
? ? ? ? ? ? ? ? String IDcard = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的性別:");
? ? ? ? ? ? ? ? String sex = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的生日(格式:2000-10-10)");
? ? ? ? ? ? ? ? String birthday = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的家庭地址:");
? ? ? ? ? ? ? ? String site = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的手機(jī)號(hào):");
? ? ? ? ? ? ? ? String phone = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的成績(jī):");
? ? ? ? ? ? ? ? int grade = sc.nextInt();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的班級(jí):");
? ? ? ? ? ? ? ? String group = sc.next();
? ? ? ? ? ? ? ? Student stu = new Student(id, name, IDcard, sex, birthday, site, phone, grade, group);
? ? ? ? ? ? ? ? students.add(stu);
? ? ? ? ? ? ? ? System.out.println("添加成功!");
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? System.out.println("您輸入的學(xué)生號(hào)已存在,請(qǐng)重新輸入!");
? ? ? ? ? ? }
? ? ? ? }


? ? }
? ? // 修改
? ? public static void updateStudent() throws ParseException {
? ? ? ? // System.out.println("修改成功!");
? ? ? ? System.out.println("請(qǐng)輸入您要修改的學(xué)生號(hào):");
? ? ? ? String id = sc.next();
? ? ? ? int index = getIndex(students,id);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的學(xué)生號(hào)不存在??!");
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? System.out.println("請(qǐng)輸入您的姓名:");
? ? ? ? String name = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的身份證:");
? ? ? ? String IDcard = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的性別:");
? ? ? ? String sex = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的生日:");
? ? ? ? String birthday = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的地址:");
? ? ? ? String site = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的手機(jī)號(hào):");
? ? ? ? String phone = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的成績(jī):");
? ? ? ? int grade = sc.nextInt();
? ? ? ? System.out.println("請(qǐng)輸入您的班級(jí):");
? ? ? ? String group = sc.next();
? ? ? ? Student stu = new Student(id,name, IDcard,sex,birthday,site,phone,grade,group);
? ? ? ? students.set(index,stu);
? ? ? ? System.out.println("修改成功!");

? ? }
? ? // 刪除
? ? public static void deleteStudent() {
// ? ? ? ?System.out.println("刪除成功!");
? ? ? ? System.out.println("請(qǐng)輸入您要?jiǎng)h除的學(xué)生號(hào):");
? ? ? ? String id = sc.next();
? ? ? ? int index = getIndex(students,id);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的學(xué)生號(hào)不存在!");
? ? ? ? ? ? return;
? ? ? ? }else{
? ? ? ? ? ? students.remove(index);
? ? ? ? ? ? System.out.println("刪除成功!");
? ? ? ? ? ? return;
? ? ? ? }

? ? }
? ? // 查看
? ? public static void selectStudent() {
? ? ? ? // System.out.println("查看成功!");
? ? ? ? int num = students.size();
? ? ? ? if(num == 0){
? ? ? ? ? ? System.out.println("暫無信息,請(qǐng)?zhí)砑右院笤趤聿榭矗?);
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? // 編號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),成績(jī),班級(jí)
? ? ? ? System.out.println("學(xué)生號(hào)\t姓名\t身份證\t性別\t生日\(chéng)t年齡\t地址\t手機(jī)號(hào)\t成績(jī)\t班級(jí)");
? ? ? ? for (int i = 0; i < students.size(); i++) {
? ? ? ? ? ? Student stu = students.get(i);
? ? ? ? ? ? System.out.println(stu.getId() + "\t" + stu.getName() + "\t" + stu.getIDcard() + "\t" + stu.getSex() + "\t" + stu.getBirthday() + "\t" + stu.getAge() + "\t" + stu.getSite() + "\t" + stu.getPhone() + "\t" + stu.getGrade() + "\t" + stu.getGroup());
? ? ? ? }
? ? }
? ? // 指定查看
? ? public static void assignStudent() {
// ? ? ? ?System.out.println("指定查看成功!");
? ? ? ? System.out.println("請(qǐng)輸入您要查找的學(xué)生號(hào):");
? ? ? ? String id = sc.next();
? ? ? ? int index = getIndex(students,id);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的學(xué)生號(hào)不存在!");
? ? ? ? }else{// ? ?// 編號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),成績(jī),班級(jí)
? ? ? ? ? ? for (int i = 0; i < students.size(); i++) {
? ? ? ? ? ? ? ? Student stu = students.get(i);
? ? ? ? ? ? ? ? System.out.println("學(xué)生號(hào):" + stu.getId());
? ? ? ? ? ? ? ? System.out.println("姓 ?名:" + stu.getName());
? ? ? ? ? ? ? ? System.out.println("生 ?日:" + stu.getBirthday());
? ? ? ? ? ? ? ? System.out.println("年 ?齡:" + stu.getAge());
? ? ? ? ? ? ? ? System.out.println("身份證:" + stu.getIDcard());
? ? ? ? ? ? ? ? System.out.println("性 ?別:" + stu.getSex());
? ? ? ? ? ? ? ? System.out.println("地 ?址:" + stu.getSite());
? ? ? ? ? ? ? ? System.out.println("手機(jī)號(hào):" + stu.getPhone());
? ? ? ? ? ? ? ? System.out.println("成 ?績(jī):" + stu.getGrade());
? ? ? ? ? ? ? ? System.out.println("班 ?級(jí):" + stu.getGroup());
? ? ? ? ? ? }

? ? ? ? }
? ? }
? ? // 統(tǒng)計(jì)
? ? public static void statisticsStudent() {
// ? ? ? ?System.out.println("統(tǒng)計(jì)成功!");
? ? ? ? int countSex = 0;
? ? ? ? int countGrade = 0;
? ? ? ? for (int i = 0; i < students.size(); i++) {
? ? ? ? ? ? Student stu = students.get(i);
? ? ? ? ? ? if(stu.getSex().equals("男")){
? ? ? ? ? ? ? ? countSex++;
? ? ? ? ? ? }
? ? ? ? ? ? if(stu.getGrade() > 60){
? ? ? ? ? ? ? ? countGrade++;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? System.out.println("學(xué)校一共有:" + students.size() + "個(gè)人");
? ? ? ? System.out.println("男生有:" + countSex + "人");
? ? ? ? System.out.println("女生有:" + (students.size() - countSex) + "人");
? ? ? ? System.out.println("及格有:" + countGrade + "人");
? ? ? ? System.out.println("不及格有:" + (students.size() - countGrade) + "人");
? ? }
? ? // 判斷學(xué)生是否存在
? ? public static int getIndex(ArrayList<Student> students,String id){
? ? ? ? int index = -1;
? ? ? ? for (int i = 0; i < students.size(); i++) {
? ? ? ? ? ? Student stu = students.get(i);
? ? ? ? ? ? String sid = stu.getId();
? ? ? ? ? ? if(sid.equals(id)){
? ? ? ? ? ? ? ? index = i;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? return index;
? ? }
? ? //===================================================================================
? ? // 教師
? ? public static void teacherSystem() throws ParseException {
? ? ? ? System.out.println("********************【歡迎來到教師管理系統(tǒng)】**************************");
? ? ? ? while (true){
? ? ? ? ? ? System.out.println("*******【1】添加教師***************************【2】 修改教師*********");
? ? ? ? ? ? System.out.println("*******【3】刪除教師***************************【4】 查看所有教師******");
? ? ? ? ? ? System.out.println("*******【5】查找指定教師************************【6】 統(tǒng)計(jì)所有教師信息**");
? ? ? ? ? ? System.out.println("***************************【7】 返回上一級(jí)***************************");
? ? ? ? ? ? System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~【請(qǐng)輸入您要選擇的編號(hào)】~~~~~~~~~~~~~~~~~~~~~~~~");
? ? ? ? ? ? String num = sc.next();
? ? ? ? ? ? // 編號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),成績(jī),班級(jí)
? ? ? ? ? ? switch (num){
? ? ? ? ? ? ? ? case "1":
? ? ? ? ? ? ? ? ? ? // 添加
? ? ? ? ? ? ? ? ? ? addTeacher();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "2":
? ? ? ? ? ? ? ? ? ? // 修改
? ? ? ? ? ? ? ? ? ? updateTeacher();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "3":
? ? ? ? ? ? ? ? ? ? // 刪除
? ? ? ? ? ? ? ? ? ? deleteTeacher();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "4":
? ? ? ? ? ? ? ? ? ? // 查看
? ? ? ? ? ? ? ? ? ? selectTeacher();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "5":
? ? ? ? ? ? ? ? ? ? // 指定查看
? ? ? ? ? ? ? ? ? ? assignTeacher();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "6":
? ? ? ? ? ? ? ? ? ? // 統(tǒng)計(jì)
? ? ? ? ? ? ? ? ? ? statisticsTeacher();
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "7":
? ? ? ? ? ? ? ? ? ? System.out.println("返回上一級(jí)");
? ? ? ? ? ? ? ? ? ? return;
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的編號(hào)" + num + "有誤!");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }

? ? ? ? }
? ? }
? ? // 添加
? ? public static void addTeacher() throws ParseException {
? ? ? ? //System.out.println("添加成功!");
? ? ? ? System.out.println("請(qǐng)輸入您的教師號(hào):");
? ? ? ? while (true) {
? ? ? ? ? ? String id = sc.next();
? ? ? ? ? ? int index = getindex(teachers, id);
? ? ? ? ? ? if (index == -1) {
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的姓名:");
? ? ? ? ? ? ? ? String name = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的身份證:");
? ? ? ? ? ? ? ? String IDcard = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的性別:");
? ? ? ? ? ? ? ? String sex = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的生日(格式:2000-10-10)");
? ? ? ? ? ? ? ? String birthday = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的家庭地址:");
? ? ? ? ? ? ? ? String site = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的手機(jī)號(hào):");
? ? ? ? ? ? ? ? String phone = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的專業(yè):");
? ? ? ? ? ? ? ? String career = sc.next();
? ? ? ? ? ? ? ? System.out.println("請(qǐng)輸入您的工資:");
? ? ? ? ? ? ? ? String salary = sc.next();
? ? ? ? ? ? ? ? Teacher teacher = new Teacher(id, name, IDcard, sex, birthday, site, phone, career, salary);
? ? ? ? ? ? ? ? teachers.add(teacher);
? ? ? ? ? ? ? ? System.out.println("添加成功!");
? ? ? ? ? ? ? ? return;
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? System.out.println("您輸入的教師號(hào)已存在,請(qǐng)重新輸入!");
? ? ? ? ? ? }
? ? ? ? }

? ? }
? ? // 修改
? ? public static void updateTeacher() throws ParseException {
? ? ? ? //System.out.println("修改成功!");
? ? ? ? System.out.println("請(qǐng)輸入您要修改的教師號(hào):");
? ? ? ? String id = sc.next();
? ? ? ? int index = getindex(teachers,id);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的教師號(hào)不存在!!");
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? System.out.println("請(qǐng)輸入您的姓名:");
? ? ? ? String name = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的身份證:");
? ? ? ? String IDcard = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的性別:");
? ? ? ? String sex = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的生日:");
? ? ? ? String birthday = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的地址:");
? ? ? ? String site = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的手機(jī)號(hào):");
? ? ? ? String phone = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的專業(yè):");
? ? ? ? String career = sc.next();
? ? ? ? System.out.println("請(qǐng)輸入您的工資:");
? ? ? ? String salary = sc.next();
? ? ? ? Teacher teacher = new Teacher(id,name, IDcard,sex,birthday,site,phone,career,salary);
? ? ? ? teachers.set(index,teacher);
? ? ? ? System.out.println("修改成功!");

? ? }
? ? // 刪除
? ? public static void deleteTeacher() {
? ? ? ? //System.out.println("刪除成功!");
? ? ? ? System.out.println("請(qǐng)輸入您要?jiǎng)h除的教師號(hào):");
? ? ? ? String id = sc.next();
? ? ? ? int index = getindex(teachers,id);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的教師號(hào)不存在!");
? ? ? ? ? ? return;
? ? ? ? }else{
? ? ? ? ? ? teachers.remove(index);
? ? ? ? ? ? System.out.println("刪除成功!");
? ? ? ? ? ? return;
? ? ? ? }

? ? }
? ? // 查看
? ? public static void selectTeacher() {
? ? ? ? //System.out.println("查看成功!");
? ? ? ? int num = teachers.size();
? ? ? ? if(num == 0){
? ? ? ? ? ? System.out.println("暫無信息,請(qǐng)?zhí)砑右院笤趤聿榭矗?);
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? // 編號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),成績(jī),班級(jí)
? ? ? ? System.out.println("教師號(hào)\t姓名\t身份證\t性別\t生日\(chéng)t年齡\t地址\t手機(jī)號(hào)\t專業(yè)\t工資");
? ? ? ? for (int i = 0; i < teachers.size(); i++) {
? ? ? ? ? ? Teacher teacher = teachers.get(i);
? ? ? ? ? ? System.out.println(teacher.getId() + "\t" + teacher.getName() + "\t" + teacher.getIDcard() + "\t" + teacher.getSex() + "\t" + teacher.getBirthday() + "\t" + teacher.getAge() + "\t" + teacher.getSite() + "\t" + teacher.getPhone() + "\t" + teacher.getCareer() + "\t" + teacher.getSalary());
? ? ? ? }

? ? }
? ? // 指定查看
? ? public static void assignTeacher() {
? ? ? ? //System.out.println("指定查看成功!");
? ? ? ? System.out.println("請(qǐng)輸入您要查找的教師號(hào):");
? ? ? ? String id = sc.next();
? ? ? ? int index = getindex(teachers,id);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的教師號(hào)不存在!");
? ? ? ? }else{// ? ?// 編號(hào),姓名,身份證,性別,生日,地址,手機(jī)號(hào),成績(jī),班級(jí)
? ? ? ? ? ? for (int i = 0; i < teachers.size(); i++) {
? ? ? ? ? ? ? ? Teacher teacher = teachers.get(i);
? ? ? ? ? ? ? ? System.out.println("教師號(hào):" + teacher.getId());
? ? ? ? ? ? ? ? System.out.println("姓 ?名:" + teacher.getName());
? ? ? ? ? ? ? ? System.out.println("生 ?日:" + teacher.getBirthday());
? ? ? ? ? ? ? ? System.out.println("年 ?齡:" + teacher.getAge());
? ? ? ? ? ? ? ? System.out.println("身份證:" + teacher.getIDcard());
? ? ? ? ? ? ? ? System.out.println("性 ?別:" + teacher.getSex());
? ? ? ? ? ? ? ? System.out.println("地 ?址:" + teacher.getSite());
? ? ? ? ? ? ? ? System.out.println("手機(jī)號(hào):" + teacher.getPhone());
? ? ? ? ? ? ? ? System.out.println("專 ?業(yè):" + teacher.getCareer());
? ? ? ? ? ? ? ? System.out.println("工 ?資:" + teacher.getCareer());
? ? ? ? ? ? }

? ? ? ? }

? ? }
? ? // 統(tǒng)計(jì)
? ? public static void statisticsTeacher() {
? ? ? ? // System.out.println("統(tǒng)計(jì)成功!");
? ? ? ? int countSex = 0;
? ? ? ? for (int i = 0; i < teachers.size(); i++) {
? ? ? ? ? ? Teacher teacher = teachers.get(i);
? ? ? ? ? ? if(teacher.getSex().equals("男")){
? ? ? ? ? ? ? ? countSex++;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? System.out.println("學(xué)校一共有:" + teachers.size() + "個(gè)教師");
? ? ? ? System.out.println("男教師有:" + countSex + "人");
? ? ? ? System.out.println("女教師有:" + (teachers.size() - countSex) + "人");
? ? }
? ? // 判斷教師是否存在
? ? public static int getindex(ArrayList<Teacher> teachers,String id){
? ? ? ? int index = -1;
? ? ? ? for (int i = 0; i < teachers.size(); i++) {
? ? ? ? ? ? Teacher teacher = teachers.get(i);
? ? ? ? ? ? String sid = teacher.getId();
? ? ? ? ? ? if(sid.equals(id)){
? ? ? ? ? ? ? ? index = i;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? return index;
? ? }

}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 詳解Java如何優(yōu)雅的使用策略模式

    詳解Java如何優(yōu)雅的使用策略模式

    設(shè)計(jì)模式是軟件設(shè)計(jì)中常見問題的典型解決方案。 它們就像能根據(jù)需求進(jìn)行調(diào)整的預(yù)制藍(lán)圖, 可用于解決代碼中反復(fù)出現(xiàn)的設(shè)計(jì)問題。今天就拿其中一個(gè)問題來分析如何優(yōu)雅的使用策略模式吧
    2023-02-02
  • 基于SpringBoot多線程@Async的使用體驗(yàn)

    基于SpringBoot多線程@Async的使用體驗(yàn)

    這篇文章主要介紹了SpringBoot多線程@Async的使用體驗(yàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • 使用Rhino讓java執(zhí)行javascript的方法實(shí)例

    使用Rhino讓java執(zhí)行javascript的方法實(shí)例

    這篇文章主要介紹了java使用Rhino執(zhí)行javascript的方法,Rhino由Mozilla開發(fā),是 JavaScript 一種基于Java的實(shí)現(xiàn)
    2013-12-12
  • Java 回調(diào)函數(shù)深入理解

    Java 回調(diào)函數(shù)深入理解

    這篇文章主要介紹了 Java 回調(diào)函數(shù)深入理解的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • 幾個(gè)好用Maven鏡像倉(cāng)庫地址(小結(jié))

    幾個(gè)好用Maven鏡像倉(cāng)庫地址(小結(jié))

    這篇文章主要介紹了幾個(gè)好用Maven鏡像倉(cāng)庫地址(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • Java流程控制之選擇結(jié)構(gòu)

    Java流程控制之選擇結(jié)構(gòu)

    這篇文章主要介紹了Java流程控制之選擇結(jié)構(gòu),主要以if單選擇結(jié)構(gòu)、if雙選擇結(jié)構(gòu)、if多選擇結(jié)構(gòu)、嵌套的if結(jié)構(gòu)、switch多選擇結(jié)構(gòu)多種選擇結(jié)構(gòu)展開全文。需要的小伙伴可以參考一下
    2021-12-12
  • Spring的自動(dòng)裝配常用注解詳解

    Spring的自動(dòng)裝配常用注解詳解

    這篇文章主要介紹了Spring的自動(dòng)裝配常用注解詳解,自動(dòng)裝配就是指 Spring 容器在不使用 <constructor-arg> 和<property> 標(biāo)簽的情況下,可以自動(dòng)裝配相互協(xié)作的 Bean 之間的關(guān)聯(lián)關(guān)系,將一個(gè) Bean 注入其他 Bean 的 Property 中,需要的朋友可以參考下
    2023-08-08
  • SprinBoot如何集成參數(shù)校驗(yàn)Validator及參數(shù)校驗(yàn)的高階技巧

    SprinBoot如何集成參數(shù)校驗(yàn)Validator及參數(shù)校驗(yàn)的高階技巧

    這篇文章主要介紹了SprinBoot如何集成參數(shù)校驗(yàn)Validator及參數(shù)校驗(yàn)的高階技巧包括自定義校驗(yàn)、分組校驗(yàn),本文分步驟給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-05-05
  • Java實(shí)現(xiàn)一個(gè)簡(jiǎn)易聊天室流程

    Java實(shí)現(xiàn)一個(gè)簡(jiǎn)易聊天室流程

    這篇文章主要介紹了我的java課程設(shè)計(jì)一個(gè)多人聊天室(socket+多線程)本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-11-11
  • Spring?IOC容器Bean注解創(chuàng)建對(duì)象組件掃描

    Spring?IOC容器Bean注解創(chuàng)建對(duì)象組件掃描

    這篇文章主要為大家介紹了Spring?IOC容器Bean注解創(chuàng)建對(duì)象組件掃描,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05

最新評(píng)論

桐城市| 徐水县| 泾阳县| 铜梁县| 宝鸡市| 三门峡市| 南京市| 屏南县| 南涧| 贺兰县| 固始县| 呼图壁县| 揭东县| 油尖旺区| 台前县| 广南县| 武汉市| 岳普湖县| 柘城县| 贵定县| 光泽县| 谢通门县| 婺源县| 济源市| 江永县| 盐边县| 柘荣县| 高安市| 永清县| 遂宁市| 达州市| 德格县| 江达县| 游戏| 凉山| 吕梁市| 安新县| 马公市| 蒙自县| 兰考县| 临安市|