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

Java實(shí)現(xiàn)班級管理系統(tǒng)

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

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

需求:班級管理系統(tǒng)

功能:對學(xué)生的信息進(jìn)行管理

1 登錄系統(tǒng)   2 退出系統(tǒng)
       賬號:
       密碼:
       驗(yàn)證碼
-----歡迎來到班級管理系統(tǒng)-----
        1 添加學(xué)生信息:
        2 刪除學(xué)生信息
        3 查找指定學(xué)生信息:
        4 查找所有學(xué)生信息
        5 統(tǒng)計(jì)班級信息
        6 退出
        請選擇您要查詢的序號:

建立一個(gè)Student類:

public class Student {
? ? private String sid; // 學(xué)號
? ? private String name; // 姓名
? ? private int age; // 年齡
? ? private String sex; // 性別
? ? private String brithday; // 生日
? ? private String constellation; // 星座
? ? private String message; // 查看班級信息
? ? public Student(){
? ? }

? ? public Student(String sid, String name, int age, String sex, String brithday, String constellation, String message) {
? ? ? ? this.sid = sid;
? ? ? ? this.name = name;
? ? ? ? this.age = age;
? ? ? ? this.sex = sex;
? ? ? ? this.brithday = brithday;
? ? ? ? this.constellation = constellation;
? ? ? ? this.message = message;
? ? }

? ? public String getSid() {
? ? ? ? return sid;
? ? }

? ? public void setSid(String sid) {
? ? ? ? this.sid = sid;
? ? }

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

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

? ? 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;
? ? }

? ? public String getBrithday() {
? ? ? ? return brithday;
? ? }

? ? public void setBrithday(String brithday) {
? ? ? ? this.brithday = brithday;
? ? }

? ? public String getConstellation() {
? ? ? ? return constellation;
? ? }

? ? public void setConstellation(String constellation) {
? ? ? ? this.constellation = constellation;
? ? }

? ? public String getMessage(){
? ? ? ? return message;
? ? }

? ? public void setMessage(String message){
? ? ? ? this.message = message;
? ? }
}

在建立一個(gè)測試類StudentDemo:

1.先實(shí)現(xiàn)界面

public static void main(String[] args) {
? ? ? ? ArrayList<Student> list = new ArrayList<>();
? ? ? ? Scanner sc = new Scanner(System.in);
? ? ? ? Random random = new Random();
? ? ? ? // 登錄系統(tǒng)
? ? ? ? lo:
? ? ? ? while(true){
? ? ? ? ? ? System.out.println("1 登錄系統(tǒng)" + " " + "2 退出系統(tǒng)");
? ? ? ? ? ? String count = sc.next();
? ? ? ? ? ? switch(count){
? ? ? ? ? ? ? ? case "1":
? ? ? ? ? ? ? ? ? ? //輸入賬號密碼
? ? ? ? ? ? ? ? ? ? int num = 0;
? ? ? ? ? ? ? ? ? ? for (int i = 0; i < 3; i++) {
? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入管理員賬號:");
? ? ? ? ? ? ? ? ? ? ? ? String uesr = sc.next();
? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入管理員密碼:");
? ? ? ? ? ? ? ? ? ? ? ? String password = sc.next();

? ? ? ? ? ? ? ? ? ? ? ? ? ? // 驗(yàn)證碼
? ? ? ? ? ? ? ? ? ? ? ? ? ? String code = "1234567890zxcvbnmlkjhgfdsaqwertyuiopZMXNCBVLAKSJDHFGQPWOEIRUTY";
? ? ? ? ? ? ? ? ? ? ? ? ? ? StringBuilder ss= new StringBuilder();
? ? ? ? ? ? ? ? ? ? ? ? ? ? int number = code.length();
? ? ? ? ? ? ? ? ? ? ? ? ? ? for (int j = 0; j < 4; j++) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int a = random.nextInt(number);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? char ch = code.charAt(a);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ss.append(ch);
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? while (true){
? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("請輸入驗(yàn)證碼:" + ss);
? ? ? ? ? ? ? ? ? ? ? ? ? ? String Code = sc.next();
? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.print("驗(yàn)證碼:" + Code);
? ? ? ? ? ? ? ? ? ? ? ? ? ? if(Code.equalsIgnoreCase(ss.toString())){
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("驗(yàn)證成功!");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的有誤,請重新輸入!");
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? if(uesr.equals("admin") && password.equals("123456")){
? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("登錄成功!");
? ? ? ? ? ? ? ? ? ? ? ? ? ? break lo;
? ? ? ? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ? ? ? num++;
? ? ? ? ? ? ? ? ? ? ? ? ? ? if(num < 3){
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的賬號或密碼錯(cuò)誤,請重新輸入!");
? ? ? ? ? ? ? ? ? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? System.out.println("您已連續(xù)三次輸入錯(cuò)誤,請24小時(shí)以后再次嘗試!");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return;
? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? case "2":
? ? ? ? ? ? ? ? ? ? return;
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的有誤,請重新輸入!");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }

? ? ? ? // 登錄界面
? ? ? ? Scanner s = new Scanner(System.in);
? ? ? ? la:
? ? ? ? while(true){
? ? ? ? ? ? System.out.println("-----歡迎來到班級管理系統(tǒng)-----");
? ? ? ? ? ? System.out.println("1 添加學(xué)生信息:");
? ? ? ? ? ? System.out.println("2 刪除學(xué)生信息");
? ? ? ? ? ? System.out.println("3 查找指定學(xué)生信息:");
? ? ? ? ? ? System.out.println("4 查找所有學(xué)生信息");
? ? ? ? ? ? System.out.println("5 統(tǒng)計(jì)班級信息");
? ? ? ? ? ? System.out.println("6 退出");
? ? ? ? ? ? System.out.println("請選擇您要查詢的序號:");

? ? ? ? ? ? // 選擇要執(zhí)行的代碼塊
? ? ? ? ? ? String num = sc.next();
? ? ? ? ? ? switch(num){
? ? ? ? ? ? ? ? case "1":
? ? ? ? ? ? ? ? ? ? // System.out.println("1 添加學(xué)生信息:");
? ? ? ? ? ? ? ? ? ? addStudent(list);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "2":
? ? ? ? ? ? ? ? ? ? // System.out.println("2 刪除學(xué)生信息");
? ? ? ? ? ? ? ? ? ? deleteStudent(list);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "3":
? ? ? ? ? ? ? ? ? ? // System.out.println("3 查找指定學(xué)生信息:");
? ? ? ? ? ? ? ? ? ? locatingStudent(list);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "4":
? ? ? ? ? ? ? ? ? ? // System.out.println("4 查找所有學(xué)生信息");
? ? ? ? ? ? ? ? ? ? setStudent(list);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "5":
? ? ? ? ? ? ? ? ? ? // System.out.println("5 統(tǒng)計(jì)班級信息");
? ? ? ? ? ? ? ? ? ? printMessage(list);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case "6":
? ? ? ? ? ? ? ? ? ? System.out.println("退出");
? ? ? ? ? ? ? ? ? ? break la;
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? System.out.println("您輸入的有誤請重新輸入!");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }

? ? ? ? }

? ? }

2.建立一個(gè)判斷系統(tǒng)中是否存在學(xué)生的類

// 判斷學(xué)生是否存在
? ? public static int getIndex(ArrayList<Student> list,String sid){
? ? ? ? int index = -1; // 無信息
? ? ? ? for (int i = 0; i < list.size(); i++) {
? ? ? ? ? ? Student stu = list.get(i);
? ? ? ? ? ? String id = stu.getSid();
? ? ? ? ? ? if(id.equals(sid)){
? ? ? ? ? ? ? ? index = i; // 學(xué)生的索引位置
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? return index;
? ? }

3.添加學(xué)生

//添加學(xué)生
? ? public static void addStudent(ArrayList<Student> list) {
? ? ? ? Scanner sc = new Scanner(System.in);
? ? ? ? String sid;
? ? ? ? while(true){
? ? ? ? ? ? System.out.println("請輸入學(xué)號");
? ? ? ? ? ? sid = sc.next();
? ? ? ? ? ? int index = getIndex(list,sid);
? ? ? ? ? ? if(index == -1){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? System.out.println("您輸入的學(xué)號已存在,請重新輸入!");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? System.out.println("請輸入您的姓名:");
? ? ? ? String name = sc.next();
? ? ? ? System.out.println("請輸入您的年齡:");
? ? ? ? int age = sc.nextInt();
? ? ? ? System.out.println("請輸入您的性別:");
? ? ? ? String sex = sc.next();
? ? ? ? System.out.println("請輸入您的生日:");
? ? ? ? String brithday = sc.next();
? ? ? ? System.out.println("請輸入您的小組:");
? ? ? ? String groud = sc.next();
? ? ? ? System.out.println("請輸入您的星座:");
? ? ? ? String constellation = sc.next();
? ? ? ? Student stu = new Student(sid,name,age,sex,brithday,groud,constellation);
? ? ? ? list.add(stu);
? ? ? ? System.out.println("添加成功!");
? ? }

4.刪除學(xué)生

// 刪除學(xué)生
? ? public static void deleteStudent(ArrayList<Student> list) {
? ? ? ? Scanner sc = new Scanner(System.in);
? ? ? ? System.out.println("請輸入您要?jiǎng)h除的學(xué)號:");
? ? ? ? String sid = sc.next();
? ? ? ? int index = getIndex(list,sid);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("您輸入的學(xué)生號不存在!");
? ? ? ? ? ? return;
? ? ? ? }else{
? ? ? ? ? ? list.remove(index);
? ? ? ? ? ? System.out.println("刪除成功!");
? ? ? ? }
? ? }

5.查找指定學(xué)生信息

// 查找指定學(xué)生
? ? public static void locatingStudent(ArrayList<Student> list) {
? ? ? ? Scanner sc = new Scanner(System.in);
? ? ? ? System.out.println("請輸入您要查找的學(xué)號:");
? ? ? ? String sid = sc.next();
? ? ? ? Student stu = new Student();
? ? ? ? int index = getIndex(list,sid);
? ? ? ? if(index == -1){
? ? ? ? ? ? System.out.println("無信息,請?zhí)砑有畔⒅笤诓檎遥?);
? ? ? ? ? ? return;
? ? ? ? }else{
? ? ? ? ? ? for (int i = 0; i < list.size(); i++) {
? ? ? ? ? ? ? ? Student a = list.get(i);
? ? ? ? ? ? ? ? System.out.println("學(xué)號:" + a.getSid());
? ? ? ? ? ? ? ? System.out.println("姓名:" + a.getName());
? ? ? ? ? ? ? ? System.out.println("年齡:" + a.getAge());
? ? ? ? ? ? ? ? System.out.println("性別:" + a.getSex());
? ? ? ? ? ? ? ? System.out.println("生日:" + a.getBrithday());
? ? ? ? ? ? ? ? System.out.println("星座:" + a.getConstellation());
? ? ? ? ? ? }
? ? ? ? }
? ? }

6.查找所有學(xué)生信息

// 查找所有學(xué)生信息
? ? public static void setStudent(ArrayList<Student> list) {
? ? ? ? int s = list.size();
? ? ? ? if(s == 0){
? ? ? ? ? ? System.out.println("暫無信息,請?zhí)砑右院笤俅尾樵儯?);
? ? ? ? ? ? return;
? ? ? ? }
? ? ? ? System.out.println("學(xué)號\t姓名\t年齡\t性別\t生日\t星座");
? ? ? ? for (int i = 0; i < list.size(); i++) {
? ? ? ? ? ? Student stu = list.get(i);
? ? ? ? ? ? System.out.println(stu.getSid() + "\t" + stu.getName() + "\t" + stu.getAge() +"\t" + stu.getSex() + "\t" + stu.getBrithday() + "\t" + stu.getConstellation());
? ? ? ? }
? ? }

7.統(tǒng)計(jì)班級的信息

// 統(tǒng)計(jì)班級信息
? ? public static void printMessage(ArrayList<Student> list) {
? ? ? ? // 多少人,男女,
? ? ? ? int count = 0;
? ? ? ? int total = list.size();

? ? ? ? for (int i = 0; i < list.size(); i++) {
? ? ? ? ? ? Student stu = list.get(i);
? ? ? ? ? ? if(stu.getSex().equals("男")){
? ? ? ? ? ? ? ? count++;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? System.out.println("班級有:" + total + "人");
? ? ? ? System.out.println("班級男生有:" + count + "人");
? ? ? ? System.out.println("班級女生有:" + (total - count) + "人");
}

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

相關(guān)文章

  • java調(diào)用openoffice將office系列文檔轉(zhuǎn)換為PDF的示例方法

    java調(diào)用openoffice將office系列文檔轉(zhuǎn)換為PDF的示例方法

    本篇文章主要介紹了java使用openoffice將office系列文檔轉(zhuǎn)換為PDF的示例方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-11-11
  • 全排列算法-遞歸與字典序的實(shí)現(xiàn)方法(Java)

    全排列算法-遞歸與字典序的實(shí)現(xiàn)方法(Java)

    下面小編就為大家?guī)硪黄帕兴惴?遞歸與字典序的實(shí)現(xiàn)方法(Java) 。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • 詳解在springmvc中解決FastJson循環(huán)引用的問題

    詳解在springmvc中解決FastJson循環(huán)引用的問題

    本篇文章主要介紹了在springmvc中解決FastJson循環(huán)引用的問題,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-01-01
  • SpringBoot跨域問題的解決方法實(shí)例

    SpringBoot跨域問題的解決方法實(shí)例

    這篇文章主要給大家介紹了關(guān)于SpringBoot跨域問題的解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-05-05
  • 適用于Java初學(xué)者的學(xué)習(xí)路線圖

    適用于Java初學(xué)者的學(xué)習(xí)路線圖

    這篇文章主要介紹了學(xué)習(xí)Java的路線圖的五個(gè)必經(jīng)階段,還有一些作者的想法分享給大家,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • SpringBoot啟動(dòng)并初始化執(zhí)行sql腳本問題

    SpringBoot啟動(dòng)并初始化執(zhí)行sql腳本問題

    這篇文章主要介紹了SpringBoot啟動(dòng)并初始化執(zhí)行sql腳本問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • Java全面講解順序表與鏈表的使用

    Java全面講解順序表與鏈表的使用

    大家好,今天給大家?guī)淼氖琼樞虮砗玩湵?,我覺得順序表還是有比較難理解的地方的,于是我就把這一塊的內(nèi)容全部整理到了一起,希望能夠給剛剛進(jìn)行學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)的人帶來一些幫助,或者是已經(jīng)學(xué)過這塊的朋友們帶來更深的理解,我們現(xiàn)在就開始吧
    2022-05-05
  • Java獲取視頻時(shí)長和封面截圖

    Java獲取視頻時(shí)長和封面截圖

    這篇文章主要為大家詳細(xì)介紹了如何使用Java獲取視頻時(shí)長和封面截圖功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-03-03
  • 基于Eclipse中SVN圖標(biāo)不顯示的解決方法

    基于Eclipse中SVN圖標(biāo)不顯示的解決方法

    本篇文章是對Eclipse中SVN圖標(biāo)不顯示的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • Spring IOC相關(guān)注解運(yùn)用(上篇)

    Spring IOC相關(guān)注解運(yùn)用(上篇)

    這篇文章主要介紹了Spring?IOC相關(guān)注解的運(yùn)用,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-05-05

最新評論

含山县| 达拉特旗| 金昌市| 清镇市| 镇巴县| 嫩江县| 五台县| 凤台县| 浦江县| 贡山| 二连浩特市| 安宁市| 临颍县| 太和县| 洪雅县| 永寿县| 巧家县| 田东县| 赣州市| 五常市| 威远县| 六枝特区| 永城市| 台南县| 兴宁市| 扶风县| 垦利县| 平南县| 彩票| 奉化市| 盐山县| 安图县| 丽水市| 临猗县| 汕头市| 西盟| 新宾| 克拉玛依市| 万源市| 繁昌县| 遂宁市|