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

java控制臺(tái)實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(集合版)

 更新時(shí)間:2021年04月28日 11:28:09   作者:沒(méi)事多喝水w  
這篇文章主要為大家詳細(xì)介紹了java控制臺(tái)實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)的集合版,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

使用java語(yǔ)言用集合存儲(chǔ)數(shù)據(jù)實(shí)現(xiàn)學(xué)生信息管理系統(tǒng),在控制臺(tái)上編譯執(zhí)行
可以實(shí)現(xiàn)基本的學(xué)生信息增加、刪除、修改、查詢(xún)功能

IO版可以參考我的另外一篇博文。

運(yùn)行界面如下

歡迎界面

添加學(xué)生信息

刪除學(xué)生信息

修改學(xué)生信息

查詢(xún)學(xué)生信息

退出系統(tǒng)

系統(tǒng)模塊結(jié)構(gòu)圖

系統(tǒng)業(yè)務(wù)流程圖

代碼如下

Student類(lèi)

public class Student {
 private String stuNo;
 private String name;
 private int age;
 public Student() {
  super();
  // TODO Auto-generated constructor stub
 }
 public Student(String stuNo, String name, int age) {
  super();
  this.stuNo = stuNo;
  this.name = name;
  this.age = age;
 }
 public String getStuNo() {
  return stuNo;
 }
 public void setStuNo(String stuNo) {
  this.stuNo = stuNo;
 }
 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;
 }
 @Override
 public int hashCode() {
  final int prime = 31;
  int result = 1;
  result = prime * result + age;
  result = prime * result + ((name == null) ? 0 : name.hashCode());
  result = prime * result + ((stuNo == null) ? 0 : stuNo.hashCode());
  return result;
 }
 @Override
 public boolean equals(Object obj) {
  if (this == obj)
   return true;
  if (obj == null)
   return false;
  if (getClass() != obj.getClass())
   return false;
  Student other = (Student) obj;
  if (age != other.age)
   return false;
  if (name == null) {
   if (other.name != null)
    return false;
  } else if (!name.equals(other.name))
   return false;
  if (stuNo == null) {
   if (other.stuNo != null)
    return false;
  } else if (!stuNo.equals(other.stuNo))
   return false;
  return true;
 }
 @Override
 public String toString() {
  return "學(xué)生:學(xué)號(hào) " + stuNo + ", 姓名 " + name + ", 年齡 " + age ;
 }
 
}

StudentDao類(lèi)

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class StudentDAO {
 static List<Student> list = new ArrayList<>();
 static String ig = "1000";
 Scanner sc = new Scanner(System.in);

 // 增加學(xué)生信息
 public void add(List<Student> list) {
  int ig = Integer.parseInt(this.ig);
  while (true) {
   System.out.println(ig);

   System.out.println("請(qǐng)輸入你要添加的學(xué)號(hào)為" + ig + "的學(xué)生的姓名");
   String name = sc.next();

   while (true) {
    System.out.println("請(qǐng)輸入你要添加的學(xué)號(hào)為" + ig + "的學(xué)生的年齡");
    Scanner sc1 = new Scanner(System.in);
    if (sc1.hasNextInt()) {
     int age = sc1.nextInt();
     list.add(new Student(String.valueOf(ig), name, age));
     break;
    } else {
     System.out.println("請(qǐng)正確輸入");
     continue;
    }
   }
   System.out.println("學(xué)號(hào)為" + ig + "的學(xué)生信息添加成功");
   ig++;
   this.ig = String.valueOf(ig);
   System.out.println("添加信息后,學(xué)生的信息為:");
   query(list);
   System.out.println("是否繼續(xù)執(zhí)行添加操作(y/n)");
   String result = sc.next();
   if (result.equalsIgnoreCase("n") || result.equalsIgnoreCase("y")) {
    if (result.equalsIgnoreCase("n")) {
     break;
    }
   }

  }
 }

 // 刪除學(xué)生信息
 public void del(List<Student> list) {
  if (list.size() != 0) {
   a: while (true) {
    query(list);
    System.out.println("請(qǐng)輸出你要?jiǎng)h除的學(xué)生的學(xué)號(hào)");
    String str = sc.next();
    Iterator<Student> it = list.iterator();
    while (it.hasNext()) {
     Student stu = it.next();

     if (stu.getStuNo().equals(str)) {
      it.remove();
      System.out.println("刪除成功!");
      System.out.println("刪除操作后,學(xué)生的信息為:");
      query(list);
      break a;// 跳出到指定循環(huán)外
     }

    }
    System.out.println("查無(wú)此人……請(qǐng)查證后重新輸入");
   }
  } else {
   System.out.println("還沒(méi)有添加學(xué)生信息,快去添加學(xué)生信息吧");
  }
 }

 // 修改學(xué)生信息
 public void update(List<Student> list) {
  if (list.size() != 0) {
   a: while (true) {
    query(list);
    System.out.println("請(qǐng)輸入要修改學(xué)生的學(xué)號(hào):");
    String stuNo = sc.next();
    ListIterator<Student> lit = list.listIterator();
    while (lit.hasNext()) {
     Student stu = lit.next();
     if (stu.getStuNo().equals(stuNo)) {
      System.out.println("請(qǐng)輸入您要修改的學(xué)生的姓名");
      String name = sc.next();
      System.out.println("請(qǐng)輸入您要修改的學(xué)生的年齡");
      if (sc.hasNextInt()) {
       int age = sc.nextInt();
       stu.setName(name);
       stu.setAge(age);
       System.out.println("修改操作后,學(xué)生的信息為:");
       query(list);
       break a;
      } else {
       System.out.println("請(qǐng)正確輸入年齡");
      }
     } 
    }
    System.out.println("查無(wú)此人……請(qǐng)查證后重新輸入");
   }
  } else {
   System.out.println("還沒(méi)有添加學(xué)生信息,快去添加學(xué)生信息吧");
  }

 }

 // 查詢(xún)學(xué)生信息
 public void query(List<Student> list) {
  if (list.size() != 0) {
   System.out.println("=============學(xué)生信息==============");
   for (Student stu : list) {
    System.out.println(stu);
   }
   System.out.println("=================================");
  } else {
   System.out.println("還沒(méi)有添加學(xué)生信息,快去添加學(xué)生信息吧");
  }
 }
}

StudentManager類(lèi)

import java.util.Scanner;

/**
 *
 * 創(chuàng)建時(shí)間:2019年12月6日 上午11:40:57
 *
 *
 */
public class StudentManager {
 public static void main(String[] args) {
  while (true) {
   Scanner sc = new Scanner(System.in);
   System.out.println();
   System.out.println();
   System.out.println("=================================");
   System.out.println("=========歡迎使用學(xué)生管理系統(tǒng) =========");
   System.out.println("=========請(qǐng)選擇您要進(jìn)行的操作 =========");
   System.out.println("=        1 添加學(xué)生信息                                 =");
   System.out.println("=        2 刪除學(xué)生信息                                 =");
   System.out.println("=        3 修改學(xué)生信息                                 =");
   System.out.println("=        4 查詢(xún)學(xué)生信息                                 =");
   System.out.println("=        5 退出系統(tǒng)                                         =");
   System.out.println("==================================");
   System.out.println("請(qǐng)輸入您的選擇");
   int choose;
   if (sc.hasNextInt()) {
    choose = sc.nextInt();
    if (choose > 0 && choose < 6) {
     Student st = new Student();
     StudentDAO std = new StudentDAO();
     switch (choose) {
     case 1:
      std.add(std.list);
      break;
     case 2:
      std.del(std.list);
      break;
     case 3:
      std.update(std.list);
      break;
     case 4:
      std.query(std.list);
      break;
     case 5:
      System.out.println("成功退出……");
      System.out.println("歡迎下次使用");
      System.exit(0);
      break;
     }
    } else {
     System.out.println("請(qǐng)正確輸入");
    }

   } else {
    System.out.println("請(qǐng)您輸入正確的選項(xiàng)");
   }
  }
 }
}

本系統(tǒng)中查詢(xún)功能不是很完善,可以實(shí)現(xiàn)功能使用查詢(xún)功能時(shí)可以選擇查詢(xún)?nèi)?、按學(xué)號(hào)查詢(xún)、按姓名分類(lèi)等不同的查詢(xún)方法。

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

相關(guān)文章

  • iReport簡(jiǎn)單使用方法圖文教程

    iReport簡(jiǎn)單使用方法圖文教程

    iReport是一個(gè)能夠創(chuàng)建復(fù)雜報(bào)表的開(kāi)源項(xiàng)目,它100%使用Java語(yǔ)言編寫(xiě),是目前全球最為流行的開(kāi)源報(bào)表設(shè)計(jì)器,由于它豐富的圖形界面,你能夠很快的創(chuàng)建出任何一種你想要的報(bào)表
    2021-10-10
  • rabbitmq結(jié)合spring實(shí)現(xiàn)消息隊(duì)列優(yōu)先級(jí)的方法

    rabbitmq結(jié)合spring實(shí)現(xiàn)消息隊(duì)列優(yōu)先級(jí)的方法

    本篇文章主要介紹了rabbitmq結(jié)合spring實(shí)現(xiàn)消息隊(duì)列優(yōu)先級(jí)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-02-02
  • springboot多數(shù)據(jù)源配置及切換的示例代碼詳解

    springboot多數(shù)據(jù)源配置及切換的示例代碼詳解

    這篇文章主要介紹了springboot多數(shù)據(jù)源配置及切換,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-09-09
  • spring簡(jiǎn)單MVC實(shí)現(xiàn)方法(URL映射及其參數(shù)使用、查詢(xún)(id、其他參數(shù))、增加)

    spring簡(jiǎn)單MVC實(shí)現(xiàn)方法(URL映射及其參數(shù)使用、查詢(xún)(id、其他參數(shù))、增加)

    這篇文章主要介紹了spring簡(jiǎn)單MVC實(shí)現(xiàn)方法(URL映射及其參數(shù)使用、查詢(xún)(id、其他參數(shù))、增加),方法參數(shù)使用包括在無(wú)注解下獲取參數(shù),使用@RequestParam 獲取參數(shù)的方法,每種方法講解的非常詳細(xì),需要的朋友可以參考下
    2024-01-01
  • java實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘并設(shè)置鬧鐘功能

    java實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘并設(shè)置鬧鐘功能

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘并設(shè)置鬧鐘功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-01-01
  • 使用RestTemplate訪(fǎng)問(wèn)https實(shí)現(xiàn)SSL請(qǐng)求操作

    使用RestTemplate訪(fǎng)問(wèn)https實(shí)現(xiàn)SSL請(qǐng)求操作

    這篇文章主要介紹了使用RestTemplate訪(fǎng)問(wèn)https實(shí)現(xiàn)SSL請(qǐng)求操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-10-10
  • 最新評(píng)論

    江门市| 日土县| 共和县| 车致| 武冈市| 昌邑市| 秦皇岛市| 乳源| 平江县| 梧州市| 佛学| 崇州市| 开封县| 二连浩特市| 綦江县| 金塔县| 噶尔县| 华坪县| 巫溪县| 涟源市| 万安县| 华宁县| 都兰县| 中宁县| 绥阳县| 苏州市| 逊克县| 澄城县| 新余市| 那曲县| 邹城市| 湖州市| 青河县| 页游| 河南省| 弋阳县| 苗栗市| 白水县| 宣汉县| 松江区| 阜平县|