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

java實(shí)現(xiàn)學(xué)生宿舍系統(tǒng)

 更新時間:2022年03月16日 16:32:46   作者:DialogD  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)學(xué)生宿舍系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

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

學(xué)生類代碼

Student.java

package dormitory;

public class Student {
? ? private String ?id;
? ? private String name;
? ? private String sex;
? ? private String dormid;
? ? 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 getSex() {
? ? ? ? return sex;
? ? }
? ? public void setSex(String sex) {
? ? ? ? this.sex = sex;
? ? }
? ? public String getDormid() {
? ? ? ? return dormid;
? ? }
? ? public void setDormid(String dormid) {
? ? ? ? this.dormid = dormid;
? ? }

}

主操作代碼

IntailStudent.java

package dormitory;
import java.awt.List;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

import javax.print.DocFlavor.INPUT_STREAM;
import javax.swing.event.ListSelectionEvent;

import org.omg.PortableInterceptor.IORInterceptor;


public class InitailStudent {
? ? private static int n=0;
? ? private static Student[] stu=new Student[100];
? ? //主函數(shù)
? ? public static void main(String[] args) throws IOException {
? ? ? ? boolean a=false;
? ? ? ? boolean b=false;
? ? ? ? InitailStudent student=new InitailStudent();
? ? ? ? student.judge(a, b);
? ? }
? ? //登入函數(shù)
? ? private void judge(boolean a, boolean b) throws IOException
? ? {
? ? ? ? do {
? ? ? ? ? ? System.out.println("歡迎進(jìn)入登入頁面!");
? ? ? ? ? ? Scanner input=new Scanner(System.in);
? ? ? ? ? ? System.out.println("請輸入賬號:");
? ? ? ? ? ? String account=input.nextLine();
? ? ? ? ? ? System.out.println("請輸入密碼:");
? ? ? ? ? ? String code=input.nextLine();
? ? ? ? ? ? a=account.equals("admin");
? ? ? ? ? ? b=code.equals("admin");
? ? ? ? } while(!(a==true&&b==true));

? ? ? ? Menu();?
? ? }

? ? //系統(tǒng)菜單頁面
? ? private void Menu() throws IOException{
? ? ? ? Scanner input=new Scanner(System.in);
? ? ? ? System.out.println("------ ?歡迎進(jìn)入宿舍管理系統(tǒng) ?------");
? ? ? ? System.out.println("------ ?請選擇下列操作 ? ? ? ? ? ? ------");
? ? ? ? System.out.println("--- ? ? 1.顯示所有學(xué)生信息 ? ? ? ? ?---"); ? ? ?//Show()
? ? ? ? System.out.println("--- ? ? 2.查詢學(xué)生信息 ? ? ? ? ? ? ? ? ---"); ? ? ?//Find()
? ? ? ? System.out.println("--- ? ? 3.增加學(xué)生信息 ? ? ? ? ? ? ? ? ---"); ? ? ?//Add()
? ? ? ? System.out.println("--- ? ? 4.修改學(xué)生信息 ? ? ? ? ? ? ? ? ---"); ? ? ?//Renew()
? ? ? ? System.out.println("--- ? ? 5.刪除學(xué)生信息 ? ? ? ? ? ? ? ? ---"); ? ? ?//Delete()
? ? ? ? System.out.println("--- ? ? 0.退出系統(tǒng) ? ? ? ? ? ? ? ? ? ? ? ? ---");
? ? ? ? System.out.println("請輸入1~5:");
? ? ? ? int a=input.nextInt();
? ? ? ? while(a<0||a>5)
? ? ? ? {
? ? ? ? ? ? System.out.println("輸入有誤,請重新輸入:");
? ? ? ? ? ? a=input.nextInt();
? ? ? ? }
? ? ? ? switch (a) {
? ? ? ? case 1:
? ? ? ? ? ? Show();
? ? ? ? ? ? break;
? ? ? ? case 2:
? ? ? ? ? ? Find();
? ? ? ? ? ? break;
? ? ? ? case 3:
? ? ? ? ? ? Add();
? ? ? ? ? ? break;
? ? ? ? case 4:
? ? ? ? ? ? Renew();
? ? ? ? ? ? break;
? ? ? ? case 5:
? ? ? ? ? ? Delete();
? ? ? ? ? ? break;
? ? ? ? case 0:
? ? ? ? ? ? System.out.println("成功退出系統(tǒng)!");
? ? ? ? ? ? System.exit(0);
? ? ? ? ? ? break;
? ? ? ? }
? ? }

? ? //顯示學(xué)生的全部信息
? ? private void Show() throws IOException{
? ? ? ? System.out.println("您總錄入的信息如下:");
? ? ? ? System.out.println("*****************************");
? ? ? ? BufferedReader br=new BufferedReader(new FileReader("student.txt"));
? ? ? ? String line;
? ? ? ? while((line=br.readLine())!=null){
? ? ? ? ? ? System.out.println(line);
? ? ? ? }
? ? ? ? br.close();
? ? ? ? System.out.println("\n\r");
? ? ? ? System.out.println("此次錄入的信息為");
? ? ? ? System.out.println("*****************************");
? ? ? ? int i;
? ? ? ? for(i=0;i<n;i++)
? ? ? ? {
? ? ? ? ? ? System.out.println("學(xué)號:"+stu[i].getId()+"\t姓名:"+stu[i].getName()+"\t性別:"+stu[i].getSex()+"\t宿舍號:"+stu[i].getDormid());
? ? ? ? }
? ? ? ? System.out.println("返回主菜單");
? ? ? ? Menu();

? ? }?

? ? //查詢學(xué)生信息
? ? private void Find() throws IOException{
? ? ? ? ArrayList<ArrayList<String>> lists = new ArrayList<>();
? ? ? ? BufferedReader br=new BufferedReader(new FileReader("student.txt"));
? ? ? ? String line;
? ? ? ? ArrayList<String> list = new ArrayList<>();
? ? ? ? ArrayList<String> validlist = new ArrayList<>();
? ? ? ? while((line=br.readLine())!=null){
? ? ? ? ? ? list.add(line.toString());
? ? ? ? }
? ? ? ? br.close();
? ? ? ? for(int i = 0;i<list.size();i++)

? ? ? ? ? ? if(i!=0&&list.get(i-1).startsWith("學(xué)號")){
? ? ? ? ? ? ? ? validlist.add(list.get(i));

? ? ? ? }
? ? ? ? for (String string : validlist) {
? ? ? ? ? ? String[] split = string.split(" ? ? ");
? ? ? ? ? ? ArrayList<String> tempString = new ArrayList<>();
? ? ? ? ? ? for (String string2 : split) {
? ? ? ? ? ? ? ? tempString.add(string2);
? ? ? ? ? ? }

? ? ? ? ? ? lists.add(tempString);
? ? ? ? } ??
? ? ? ? System.out.println("共有"+lists.size()+"個學(xué)生信息");
? ? ? ? String[][] stu1=new String[lists.size()][4];
? ? ? ? for(int i=0;i<lists.size();i++)
? ? ? ? ? ? for(int j=0;j<4;j++){
? ? ? ? ? ? ? ? stu1[i][j]=lists.get(i).get(j);
? ? ? ? ? ? }
? ? ? ? System.out.println("請輸入學(xué)生的學(xué)號:");
? ? ? ? Scanner input=new Scanner(System.in);
? ? ? ? String ?d=input.next();
? ? ? ? for(int i=0;i<stu1.length;i++)
? ? ? ? {
? ? ? ? ? ? if(d.equals(stu1[i][0]))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("查詢成功,以下為該學(xué)生的信息");
? ? ? ? ? ? ? ? System.out.println("學(xué)號:"+stu1[i][0]+"\t姓名:"+stu1[i][1]+"\t性別:"+stu1[i][2]+"\t宿舍號:"+stu1[i][3]);
? ? ? ? ? ? ? ? System.out.println("是否繼續(xù)查詢,否返回菜單,是Y否N");
? ? ? ? ? ? ? ? String cho=input.next();
? ? ? ? ? ? ? ? char ch=cho.charAt(0);
? ? ? ? ? ? ? ? while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? System.out.println("輸入有誤!請重新輸入:");
? ? ? ? ? ? ? ? ? ? cho=input.next();
? ? ? ? ? ? ? ? ? ? ch=cho.charAt(0);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? while(ch=='Y'||ch=='y'){
? ? ? ? ? ? ? ? ? ? Find();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? while(ch=='N'||ch=='n'){
? ? ? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? ? ? }

? ? ? ? ? ? }
? ? ? ? }
? ? ? ? System.out.println("沒有找到該學(xué)生,是繼續(xù)輸入,否返回菜單,是Y否N");
? ? ? ? String cho=input.next();
? ? ? ? char ch=cho.charAt(0);
? ? ? ? while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
? ? ? ? {
? ? ? ? ? ? System.out.println("輸入有誤!請重新輸入:");
? ? ? ? ? ? cho=input.next();
? ? ? ? ? ? ch=cho.charAt(0);
? ? ? ? }
? ? ? ? while(ch=='Y'||ch=='y'){
? ? ? ? ? ? Find();
? ? ? ? }
? ? ? ? while(ch=='N'||ch=='n'){
? ? ? ? ? ? Menu();
? ? ? ? }
? ? }

? ? //增加一個學(xué)生
? ? private void Add() throws IOException{
? ? ? ? String ?id;
? ? ? ? String dormid;
? ? ? ? String name;
? ? ? ? String sex;
? ? ? ? String cho;
? ? ? ? char ch;
? ? ? ? stu[n]=new Student();
? ? ? ? Scanner input=new Scanner(System.in);
? ? ? ? if(n==0)
? ? ? ? {

? ? ? ? ? ? System.out.println("您此次還沒有錄入任何信息,是否錄入,是Y否N");
? ? ? ? ? ? cho=input.next();
? ? ? ? ? ? ch=cho.charAt(0);

? ? ? ? ? ? while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("輸入有誤!請重新輸入:");
? ? ? ? ? ? ? ? cho=input.next();
? ? ? ? ? ? ? ? ch=cho.charAt(0);
? ? ? ? ? ? }

? ? ? ? ? ? while(ch=='Y'||ch=='y'){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? ? ? while(ch=='N'||ch=='n'){
? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? FileWriter fw=new FileWriter("student.txt",true);
? ? ? ? fw.write("\r\n");
? ? ? ? fw.write("學(xué)號 ? ? ? ?姓名 ? ? ?性別 ? ? ?宿舍號 \r\n");
? ? ? ? System.out.println("請輸入學(xué)生的學(xué)號:");
? ? ? ? id=input.next();
? ? ? ? stu[n].setId(id);
? ? ? ? fw.write(stu[n].getId()+" ? ? ? ");
? ? ? ? System.out.println("請輸入學(xué)生的姓名:");
? ? ? ? name=input.next();
? ? ? ? stu[n].setName(name);
? ? ? ? fw.write(stu[n].getName()+" ? ? ");
? ? ? ? System.out.println("請輸入學(xué)生的性別:");
? ? ? ? sex=input.next();
? ? ? ? stu[n].setSex(sex);
? ? ? ? fw.write(stu[n].getSex()+" ? ? ?");
? ? ? ? System.out.println("請輸入學(xué)生的宿舍號:");
? ? ? ? dormid=input.next();
? ? ? ? stu[n].setDormid(dormid);
? ? ? ? fw.write(stu[n].getDormid()+" ? ? ? ");
? ? ? ? n++;
? ? ? ? fw.close();
? ? ? ? System.out.println("是否繼續(xù)添加學(xué)生?否返回主菜單,是Y否N");
? ? ? ? cho=input.next();
? ? ? ? ch=cho.charAt(0);
? ? ? ? while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
? ? ? ? {
? ? ? ? ? ? System.out.println("輸入有誤!請重新輸入:");
? ? ? ? ? ? cho=input.next();
? ? ? ? ? ? ch=cho.charAt(0);
? ? ? ? }
? ? ? ? while(ch=='Y'||ch=='y'){
? ? ? ? ? ? Add();
? ? ? ? }
? ? ? ? while(ch=='N'||ch=='n'){
? ? ? ? ? ? Menu();
? ? ? ? }
? ? }

? ? //修改學(xué)生信息
? ? private void Renew() throws IOException{
? ? ? ? ArrayList<ArrayList<String>> lists = new ArrayList<>();
? ? ? ? BufferedReader br=new BufferedReader(new FileReader("student.txt"));
? ? ? ? String line;
? ? ? ? ArrayList<String> list = new ArrayList<>();
? ? ? ? ArrayList<String> validlist = new ArrayList<>();
? ? ? ? while((line=br.readLine())!=null){
? ? ? ? ? ? list.add(line.toString());
? ? ? ? }
? ? ? ? br.close();
? ? ? ? for(int i = 0;i<list.size();i++)

? ? ? ? ? ? if(i!=0&&list.get(i-1).startsWith("學(xué)號")){
? ? ? ? ? ? ? ? validlist.add(list.get(i));

? ? ? ? }
? ? ? ? for (String string : validlist) {
? ? ? ? ? ? String[] split = string.split(" ? ? ");
? ? ? ? ? ? ArrayList<String> tempString = new ArrayList<>();
? ? ? ? ? ? for (String string2 : split) {
? ? ? ? ? ? ? ? tempString.add(string2);
? ? ? ? ? ? }

? ? ? ? ? ? lists.add(tempString);
? ? ? ? } ??
? ? ? ? String[][] stu1=new String[lists.size()][4];
? ? ? ? for(int i=0;i<lists.size();i++)
? ? ? ? ? ? for(int j=0;j<4;j++){
? ? ? ? ? ? ? ? stu1[i][j]=lists.get(i).get(j);
? ? ? ? ? ? }

? ? ? ? int temp=0;
? ? ? ? boolean flag=false;
? ? ? ? System.out.println("請輸入要修改學(xué)生的學(xué)號:");
? ? ? ? Scanner input=new Scanner(System.in);
? ? ? ? String ?d=input.next();
? ? ? ? for(int i=0;i<stu1.length;i++)
? ? ? ? {
? ? ? ? ? ? while(d.equals(stu1[i][0]))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? temp=i;
? ? ? ? ? ? ? ? flag=true;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? if(!flag)
? ? ? ? {
? ? ? ? ? ? System.out.println("輸入的學(xué)號有誤,未找到該學(xué)生,是否再次進(jìn)入修改,是Y,否N");
? ? ? ? ? ? String cho1=input.next();
? ? ? ? ? ? char ch1=cho1.charAt(0);
? ? ? ? ? ? while (ch1!='N'&&ch1!='n'&&ch1!='Y'&&ch1!='y')
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("輸入無效,請重新輸入:");
? ? ? ? ? ? ? ? cho1=input.next();
? ? ? ? ? ? ? ? ch1=cho1.charAt(0);
? ? ? ? ? ? }
? ? ? ? ? ? if (ch1=='y'||ch1=='Y'){
? ? ? ? ? ? ? ? Renew();
? ? ? ? ? ? }
? ? ? ? ? ? if (ch1=='N'||ch1=='n'){
? ? ? ? ? ? ? ? System.out.println("返回主菜單");
? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? }?
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? System.out.println("您要修改的學(xué)生的信息如下:");
? ? ? ? ? ? System.out.println("學(xué)號:"+stu1[temp][0]+"\t姓名:"+stu1[temp][1]+"\t性別:"+stu1[temp][2]+"\t宿舍號:"+stu1[temp][3]);
? ? ? ? ? ? System.out.println("請以下選擇要修改的內(nèi)容:");
? ? ? ? ? ? System.out.println("------ ? 1.姓名 ? ? ? ------");
? ? ? ? ? ? System.out.println("------ ? 2.性別 ? ? ? ------");
? ? ? ? ? ? System.out.println("------ ? 3.宿舍號 ? ? ?------");
? ? ? ? ? ? Scanner input1=new Scanner(System.in);
? ? ? ? ? ? int a=input1.nextInt();
? ? ? ? ? ? if(a==1)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("請輸入新的姓名:");
? ? ? ? ? ? ? ? String name=input1.next();
? ? ? ? ? ? ? ? stu1[temp][1]=name;
? ? ? ? ? ? ? ? FileWriter fw1=new FileWriter("student.txt");
? ? ? ? ? ? ? ? fw1.write(" ? ? ?");
? ? ? ? ? ? ? ? fw1.close();
? ? ? ? ? ? ? ? FileWriter fw=new FileWriter("student.txt",true);
? ? ? ? ? ? ? ? fw.write("\r\n"+" ? ? ? ? ? "+"學(xué)生信息表\r\n");
? ? ? ? ? ? ? ? for(int i=0;i<stu1.length;i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? fw.write("\r\n學(xué)號 ? ? ? ?姓名 ? ? ?性別 ? ? ?宿舍號 \r\n");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][0]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][1]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][2]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][3]+" ? ? ? ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? fw.close();
? ? ? ? ? ? ? ? System.out.println("修改成功!");
? ? ? ? ? ? ? ? System.out.println("還要繼續(xù)修改嗎?是繼續(xù)修改,否返回主菜單,是Y否N");
? ? ? ? ? ? ? ? String cho1=input1.next();
? ? ? ? ? ? ? ? char ch1=cho1.charAt(0);
? ? ? ? ? ? ? ? while (ch1!='N'&&ch1!='n'&&ch1!='Y'&&ch1!='y')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? System.out.println("輸入無效,請重新輸入:");
? ? ? ? ? ? ? ? ? ? cho1=input.next();
? ? ? ? ? ? ? ? ? ? ch1=cho1.charAt(0);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (ch1=='y'||ch1=='Y'){
? ? ? ? ? ? ? ? ? ? Renew();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (ch1=='N'||ch1=='n'){
? ? ? ? ? ? ? ? ? ? System.out.println("返回主菜單");
? ? ? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? ? ? }?
? ? ? ? ? ? }
? ? ? ? ? ? else if(a==2)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("請輸入新的性別:");
? ? ? ? ? ? ? ? String sex=input1.next();
? ? ? ? ? ? ? ? stu1[temp][2]=sex;
? ? ? ? ? ? ? ? FileWriter fw1=new FileWriter("student.txt");
? ? ? ? ? ? ? ? fw1.write(" ? ? ?");
? ? ? ? ? ? ? ? fw1.close();
? ? ? ? ? ? ? ? FileWriter fw=new FileWriter("student.txt",true);
? ? ? ? ? ? ? ? fw.write("\r\n"+" ? ? ? ? ? "+"學(xué)生信息表\r\n");
? ? ? ? ? ? ? ? for(int i=0;i<stu1.length;i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? fw.write("\r\n學(xué)號 ? ? ? ?姓名 ? ? ?性別 ? ? ?宿舍號 \r\n");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][0]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][1]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][2]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][3]+" ? ? ? ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? fw.close();
? ? ? ? ? ? ? ? System.out.println("修改成功!");
? ? ? ? ? ? ? ? System.out.println("還要繼續(xù)修改嗎?是繼續(xù)修改,否返回主菜單,是Y否N");
? ? ? ? ? ? ? ? String cho1=input1.next();

? ? ? ? ? ? ? ? char ch1=cho1.charAt(0);
? ? ? ? ? ? ? ? while (ch1!='N'&&ch1!='n'&&ch1!='Y'&&ch1!='y')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? System.out.println("輸入無效,請重新輸入:");
? ? ? ? ? ? ? ? ? ? cho1=input.next();
? ? ? ? ? ? ? ? ? ? ch1=cho1.charAt(0);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (ch1=='y'||ch1=='Y'){
? ? ? ? ? ? ? ? ? ? Renew();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (ch1=='N'||ch1=='n'){
? ? ? ? ? ? ? ? ? ? System.out.println("返回主菜單");
? ? ? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? ? ? }?
? ? ? ? ? ? }
? ? ? ? ? ? else if(a==3)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("請輸入新的宿舍號:");
? ? ? ? ? ? ? ? String ?dormid=input1.next();
? ? ? ? ? ? ? ? stu1[temp][3]=dormid;
? ? ? ? ? ? ? ? FileWriter fw1=new FileWriter("student.txt");
? ? ? ? ? ? ? ? fw1.write(" ? ? ?");
? ? ? ? ? ? ? ? fw1.close();
? ? ? ? ? ? ? ? FileWriter fw=new FileWriter("student.txt",true);
? ? ? ? ? ? ? ? fw.write("\r\n"+" ? ? ? ? ? "+"學(xué)生信息表\r\n");
? ? ? ? ? ? ? ? for(int i=0;i<stu1.length;i++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? fw.write("\r\n學(xué)號 ? ? ? ?姓名 ? ? ?性別 ? ? ?宿舍號 \r\n");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][0]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][1]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][2]+" ? ? ? ");
? ? ? ? ? ? ? ? ? ? fw.write(stu1[i][3]+" ? ? ? ");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? fw.close();
? ? ? ? ? ? ? ? System.out.println("修改成功!");
? ? ? ? ? ? ? ? System.out.println("還要繼續(xù)修改嗎?是繼續(xù)修改,否返回主菜單,是Y否N");
? ? ? ? ? ? ? ? String cho1=input1.next();
? ? ? ? ? ? ? ? char ch1=cho1.charAt(0);
? ? ? ? ? ? ? ? while (ch1!='N'&&ch1!='n'&&ch1!='Y'&&ch1!='y')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? System.out.println("輸入無效,請重新輸入:");
? ? ? ? ? ? ? ? ? ? cho1=input.next();
? ? ? ? ? ? ? ? ? ? ch1=cho1.charAt(0);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (ch1=='y'||ch1=='Y'){
? ? ? ? ? ? ? ? ? ? Renew();
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if (ch1=='N'||ch1=='n'){
? ? ? ? ? ? ? ? ? ? System.out.println("返回主菜單");
? ? ? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? ? ? }?
? ? ? ? ? ? }
? ? ? ? ? ? else {
? ? ? ? ? ? ? ? System.out.println("輸入有誤,請重新輸入:");
? ? ? ? ? ? ? ? Renew();
? ? ? ? ? ? }
? ? ? ? }
? ? }

? ? //刪除學(xué)生信息
? ? private void Delete() throws IOException{
? ? ? ? ArrayList<ArrayList<String>> lists = new ArrayList<>();
? ? ? ? BufferedReader br=new BufferedReader(new FileReader("student.txt"));
? ? ? ? String line;
? ? ? ? ArrayList<String> list = new ArrayList<>();
? ? ? ? ArrayList<String> validlist = new ArrayList<>();
? ? ? ? while((line=br.readLine())!=null){
? ? ? ? ? ? list.add(line.toString());
? ? ? ? }
? ? ? ? br.close();
? ? ? ? for(int i = 0;i<list.size();i++)

? ? ? ? ? ? if(i!=0&&list.get(i-1).startsWith("學(xué)號")){
? ? ? ? ? ? ? ? validlist.add(list.get(i));

? ? ? ? }
? ? ? ? for (String string : validlist) {
? ? ? ? ? ? String[] split = string.split(" ? ? ");
? ? ? ? ? ? ArrayList<String> tempString = new ArrayList<>();
? ? ? ? ? ? for (String string2 : split) {
? ? ? ? ? ? ? ? tempString.add(string2);
? ? ? ? ? ? }

? ? ? ? ? ? lists.add(tempString);
? ? ? ? }
? ? ? ? String[][] stu1=new String[lists.size()][4];
? ? ? ? for(int i=0;i<lists.size();i++)
? ? ? ? ? ? for(int j=0;j<4;j++){
? ? ? ? ? ? ? ? stu1[i][j]=lists.get(i).get(j);
? ? ? ? ? ? }
? ? ? ? int temp=0;
? ? ? ? boolean flag=true;
? ? ? ? System.out.println("請輸入你想要刪除該學(xué)生的學(xué)號:");
? ? ? ? Scanner input2=new Scanner(System.in);
? ? ? ? String ?d=input2.next();
? ? ? ? for(int i=0;i<stu1.length;i++)
? ? ? ? {
? ? ? ? ? ? while(d.equals(stu1[i][0]))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? temp=i;
? ? ? ? ? ? ? ? flag=true;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? if(!flag)
? ? ? ? {
? ? ? ? ? ? System.out.println("輸入的學(xué)號有誤,未找到該學(xué)生,再次進(jìn)入刪除,請重新輸入:");
? ? ? ? ? ? String cho1=input2.next();
? ? ? ? ? ? char ch1=cho1.charAt(0);
? ? ? ? ? ? while (ch1!='N'&&ch1!='n'&&ch1!='Y'&&ch1!='y')
? ? ? ? ? ? {
? ? ? ? ? ? ? ? System.out.println("輸入無效,請重新輸入:");
? ? ? ? ? ? ? ? cho1=input2.next();
? ? ? ? ? ? ? ? ch1=cho1.charAt(0);
? ? ? ? ? ? }
? ? ? ? ? ? if (ch1=='y'||ch1=='Y'){
? ? ? ? ? ? ? ? Delete();
? ? ? ? ? ? }
? ? ? ? ? ? if (ch1=='N'||ch1=='n'){
? ? ? ? ? ? ? ? System.out.println("返回主菜單");
? ? ? ? ? ? ? ? Menu();
? ? ? ? ? ? }?

? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? System.out.println("您要刪除的學(xué)生的信息如下:");
? ? ? ? ? ? System.out.println("學(xué)號:"+stu1[temp][0]+"\t姓名:"+stu1[temp][1]+"\t性別:"+stu1[temp][2]+"\t宿舍號:"+stu1[temp][3]);
? ? ? ? ? ? for (int i=temp;i<stu1.length-1;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? stu1[i]=stu1[i+1];
? ? ? ? ? ? }
? ? ? ? ? ? FileWriter fw1=new FileWriter("student.txt");
? ? ? ? ? ? fw1.write(" ? ? ?");
? ? ? ? ? ? fw1.close();
? ? ? ? ? ? FileWriter fw=new FileWriter("student.txt",true);
? ? ? ? ? ? fw.write("\r\n"+" ? ? ? ? ? "+"學(xué)生信息表\r\n");
? ? ? ? ? ? for(int i=0;i<stu1.length-1;i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? fw.write("\r\n學(xué)號 ? ? ? ?姓名 ? ? ?性別 ? ? ?宿舍號 \r\n");
? ? ? ? ? ? ? ? fw.write(stu1[i][0]+" ? ? ? ");
? ? ? ? ? ? ? ? fw.write(stu1[i][1]+" ? ? ? ");
? ? ? ? ? ? ? ? fw.write(stu1[i][2]+" ? ? ? ");
? ? ? ? ? ? ? ? fw.write(stu1[i][3]+" ? ? ? ");
? ? ? ? ? ? }
? ? ? ? ? ? fw.close(); ??
? ? ? ? ? ? System.out.println("刪除該學(xué)生信息成功!");
? ? ? ? ? ? System.out.println("---------------------");
? ? ? ? }
? ? ? ? System.out.println("還要繼續(xù)刪除嗎?是繼續(xù)刪除,否返回主菜單,是Y否N");
? ? ? ? String cho2=input2.next();
? ? ? ? char ch2=cho2.charAt(0);
? ? ? ? while (ch2!='N'&&ch2!='n'&&ch2!='Y'&&ch2!='y')
? ? ? ? {
? ? ? ? ? ? System.out.println("輸入無效,請重新輸入:");
? ? ? ? ? ? cho2=input2.next();
? ? ? ? ? ? ch2=cho2.charAt(0);
? ? ? ? }
? ? ? ? if (ch2=='y'||ch2=='Y'){
? ? ? ? ? ? Delete();
? ? ? ? }
? ? ? ? if (ch2=='N'||ch2=='n'){
? ? ? ? ? ? System.out.println("返回主菜單");
? ? ? ? ? ? Menu();
? ? ? ? }?

? ? }
?}

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

相關(guān)文章

  • SpringBoot整合redis+Aop防止重復(fù)提交的實(shí)現(xiàn)

    SpringBoot整合redis+Aop防止重復(fù)提交的實(shí)現(xiàn)

    Spring Boot通過AOP可以實(shí)現(xiàn)防止表單重復(fù)提交,本文主要介紹了SpringBoot整合redis+Aop防止重復(fù)提交的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • java String 可變性的分析

    java String 可變性的分析

    這篇文章主要介紹了java String 可變性的分析的相關(guān)資料,通常大家都認(rèn)為java String 是不可變的,這里分析下源碼來說明它的可變性,需要的朋友可以參考下
    2017-03-03
  • AspectJ的基本用法

    AspectJ的基本用法

    本文主要介紹了AspectJ的基本用法。具有很好的參考價(jià)值。下面跟著小編一起來看下吧
    2017-04-04
  • IDEA如何導(dǎo)入已有Maven項(xiàng)目

    IDEA如何導(dǎo)入已有Maven項(xiàng)目

    導(dǎo)入Maven項(xiàng)目到IDEA時,經(jīng)常遇到問題,本文記錄正確步驟,首先創(chuàng)建空項(xiàng)目,然后選擇Import Module from external model并選擇Maven,勾選所需profiles和Maven項(xiàng)目,最后設(shè)置Project SDK,這樣配置后,項(xiàng)目結(jié)構(gòu)將符合預(yù)期,僅顯示一個Module
    2024-11-11
  • Java 反射獲取類詳細(xì)信息的常用方法總結(jié)

    Java 反射獲取類詳細(xì)信息的常用方法總結(jié)

    Java 反射獲取類詳細(xì)信息的常用方法總結(jié),需要的朋友可以參考一下
    2013-03-03
  • Java并發(fā)之嵌套管程鎖死詳解

    Java并發(fā)之嵌套管程鎖死詳解

    這篇文章主要介紹了Java并發(fā)之嵌套管程鎖死詳解,涉及嵌套管程鎖死的發(fā)生,實(shí)例等相關(guān)內(nèi)容,具有一定參考價(jià)值,需要的朋友可以了解下。
    2017-11-11
  • Java利用Request請求獲取IP地址的方法詳解

    Java利用Request請求獲取IP地址的方法詳解

    在開發(fā)中我們經(jīng)常需要獲取用戶IP地址,通過地址來實(shí)現(xiàn)一些功能,下面這篇文章主要給大家介紹了關(guān)于Java利用Request請求獲取IP地址的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • 在java中使用SPI創(chuàng)建可擴(kuò)展的應(yīng)用程序操作

    在java中使用SPI創(chuàng)建可擴(kuò)展的應(yīng)用程序操作

    這篇文章主要介紹了在java中使用SPI創(chuàng)建可擴(kuò)展的應(yīng)用程序操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • SpringBoot實(shí)現(xiàn)微信及QQ綁定登錄的示例代碼

    SpringBoot實(shí)現(xiàn)微信及QQ綁定登錄的示例代碼

    本文主要介紹了SpringBoot實(shí)現(xiàn)微信及QQ綁定登錄的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • SpringBoot集成RocketMQ的使用示例

    SpringBoot集成RocketMQ的使用示例

    RocketMQ是阿里巴巴開源的一款消息中間件,性能優(yōu)秀,功能齊全,被廣泛應(yīng)用在各種業(yè)務(wù)場景,本文就來介紹一下SpringBoot集成RocketMQ的使用示例,感興趣的可以了解一下
    2023-11-11

最新評論

吉安县| 读书| 房产| 甘洛县| 象山县| 子长县| 芒康县| 东兰县| 沈丘县| 咸宁市| 白玉县| 烟台市| 阿克| 高淳县| 昭苏县| 武乡县| 保亭| 兴文县| 永康市| 阿荣旗| 苍溪县| 姜堰市| 吉隆县| 绍兴市| 沅陵县| 滕州市| 泰来县| 廉江市| 景宁| 绥滨县| 桐柏县| 东光县| 贵溪市| 昂仁县| 保山市| 盘锦市| 东宁县| 丹棱县| 屏山县| 谢通门县| 巢湖市|