主頁 > 軟體設計 > 圖書館操作管理系統

圖書館操作管理系統

2021-04-21 16:19:06 軟體設計

圖書管理系統:

本系統所用知識點:
● java基本語法
● 使用流程控制
● 面向物件思想
● 封裝,繼承,多型
● 使用集合
● I/o流相關操作

模塊類別:
本系統功能分為讀者資訊管理模塊、圖書資訊管理模塊、圖書借閱管理模塊、基礎資訊維護模塊和用戶管理模塊,

模塊結構:
模塊結構

本系統需建立的類:
在這里插入圖片描述
注:Test為主類,內含主方法,其他類別下面會一一列出,

Test類:

import Library.Library;

import java.io.IOException;
import java.text.ParseException;

public class Test {
    public static void main(String[] args) throws IOException, ParseException {
        Library library = new Library();
        library.Interface();
    }
}

圖書管理系統面向管理員和用戶兩類人員,但是他們需要先登錄,下面列出登錄、注冊功能模塊及管理員與用戶的功能模塊:

登錄、注冊:

package Library;

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

import User.User;
import User.Admin;

public class Library {
    Scanner sc = new Scanner(System.in);
    private String operator;

    //用戶注冊登錄
    public void Interface() throws IOException, ParseException {
        boolean a = true;
        File file = new File("用戶資訊.txt");
        try {
            while (a) {
                System.out.println("==================圖書管理系統==================");
                System.out.println("請登錄:1.普通用戶  2.管理員登錄  3.注冊 4.退出系統");
                int i = sc.nextInt();
                if (i < 1 || i > 4) {
                    System.out.println("到底能不能行?能不能看明白了再輸!");
                } else if (i == 4) {
                    a = false;
                } else if (i == 1) {
                    //普通用戶登錄
                    System.out.println("請輸入您的用戶名:");
                    operator = sc.next();
                    //寫日志
                    File journal = new File("日志.txt");
                    Date nowDate = new Date();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                    String borrowTime = sdf.format(nowDate);
                    FileWriter jfw = new FileWriter(journal, true);
                    jfw.write(borrowTime + " " + operator + "登錄系統" + "\n");
                    jfw.write("--------------------------------");
                    jfw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                    jfw.close();//流的關閉

                    System.out.println("請輸入您的密碼:");
                    String password = sc.next();
                    FileInputStream intput = new FileInputStream(file);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
                    String tempString;
                    List<String> list = new ArrayList<>();
                    while ((tempString = reader.readLine()) != null) {
                        list.add(tempString);
                    }
                    //判斷輸入的用戶名是否存在
                    boolean flag = false;
                    String[] userinf = new String[5];
                    for (String user : list) {
                        userinf = user.split(",");
                        if (operator.equals(userinf[0])) { //判斷用戶名是否存在
                            flag = true;
                            break;
                        }
                    }
                    //如果存在,判斷密碼是否正確
                    if (flag == true) {

                        if (password.equals(userinf[1])) {
                            System.out.println("登陸成功");
                            //登錄
                            try {
                                User user = new User();
                                user.operation(userinf, operator);
                            } catch (Exception e) {
                                System.out.println("到底能不能行?能不能看明白了再輸!");
                                User user = new User();
                                user.operation(userinf, operator);
                            }
                        } else {
                            System.out.println("密碼錯誤");
                        }

                    } else {
                        System.out.println("用戶名不存在");
                    }
                    intput.close();
                    reader.close();
                } else if (i == 2) {
                    //管理員登錄
                    System.out.println("請輸入管理員密碼!");
                    String rootPassword = sc.next();
                    if (rootPassword.equals("88888888")) {
                        //管理員登錄成功
                        System.out.println("管理員登陸成功!");
                        try {
                            Admin admin = new Admin();
                            admin.admin();
                        } catch (Exception e) {
                            System.out.println("到底能不能行?能不能看明白了再輸!");
                            Admin admin = new Admin();
                            admin.admin();
                        }

                    } else {
                        System.out.println("你是不是管理員心里沒個ACD數嗎?");
                    }
                } else if (i == 3) {
                    //注冊
                    String[] userinf = new String[5];
                    FileInputStream intput = new FileInputStream(file);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
                    String tempString;
                    List<String> list = new ArrayList<>();
                    while ((tempString = reader.readLine()) != null) {
                        list.add(tempString);
                    }
                    System.out.println("請輸入您的用戶名:");
                    String name = sc.next();
                    //查找是否有同名用戶
                    boolean flag = false;
                    for (String user1 : list) {
                        userinf = user1.split(",");
                        if (name.equals(userinf[0])) { //判斷用戶名是否存在
                            System.out.println("該用戶名已存在,請重新擬取名稱");
                            flag = true;
                            break;
                        }
                    }
                    if (flag == false) {
                        System.out.println("請設定您的密碼:");
                        String password = sc.next();
                        String sex;
                        while (true) {
                            System.out.println("請輸入您的性別:");
                            sex = sc.next();
                            if (sex.equals("男") || sex.equals("女")) {
                                break;
                            } else {
                                System.out.println("別鬧!認真點,輸入正確的性別!");
                            }
                        }
                        int age;
                        while (true) {
                            System.out.println("請輸入您的年齡:");
                            age = sc.nextInt();
                            if (age < 10 && age > 0) {
                                System.out.println("您的年齡太小啦!請讓家長使用賬號幫您借閱書籍!");
                                break;
                            } else if (age <= 0) {
                                System.out.println("你是魔鬼嗎?");
                            }else{
                                break;
                            }
                        }

                        long phone;
                        while (true) {
                            System.out.println("請輸入該您的電話號碼:");
                            phone = sc.nextInt();
                            if (phone < 0) {
                                System.out.println("您是真的陰間人!");
                            } else {
                                break;
                            }
                        }
                        User user = new User(name, sex, age, phone, password);
                        file.createNewFile();
                        FileWriter fw = new FileWriter(file, true);
                        fw.write(user.toString());
                        fw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                        fw.close();
                        System.out.println("恭喜您,注冊成功!");
                    }
                }
            }


        } catch (Exception e) {
            System.out.println("到底能不能行?能不能看明白了再輸!");
            Library library = new Library();
            library.Interface();
            return;
        }

    }
}

管理員:

package User;

import Book.AddBook;
import Book.DeleteBook;
import Book.FindBook;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Admin {


    public Admin() {
    }

    public void admin() throws IOException {
        File adminBook = new File("書籍.txt");
        File adminUser = new File("用戶資訊.txt");
        FindBook fb = new FindBook();
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("===============圖書管理員操作界面===============");
            System.out.println("1.查詢書籍 2.添加書籍 3.洗掉書籍 4.增/刪用戶 5.查看用戶操作 6.回傳");
            int choice = scanner.nextInt();
            if (choice < 1 || choice > 6) {
                System.out.println("到底能不能行?能不能看明白了再輸!");
            } else if (choice == 6) {
                return;
            } else if (choice == 1) {
                //查詢書籍
                fb.adminFindBook();
            } else if (choice == 2) {
                //添加書籍
                AddBook ab = new AddBook();
                ab.addBook();
            } else if (choice == 3) {
                //洗掉書籍
                DeleteBook db = new DeleteBook();
                db.deleteBook();
            } else if (choice == 4) {
                //增刪用戶
                System.out.println("==========增/刪用戶==========");
                System.out.println("1.增加用戶 2.洗掉用戶 3.回傳");
                int decision = scanner.nextInt();
                if (decision == 3){
                    //回傳
                    break;
                }else if (decision == 1){
                    //增加用戶
                    AddUser au = new AddUser();
                    au.addUser();
                }else if (decision == 2){
                    //洗掉用戶
                    DeleteUser du = new DeleteUser();
                    du.deleteUser();
                }
            }else if (choice == 5){
                //查看用戶操作
                File file = new File("日志.txt");
                FileInputStream intput = new FileInputStream(file);
                BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
                String tempString;
                List<String> list = new ArrayList<>();
                while ((tempString = reader.readLine()) != null) {
                    System.out.println(tempString);
                }
                while (true) {
                    int a;
                    System.out.println("是否清空操作記錄:");
                    System.out.println("1、是  2、否");
                    a = scanner.nextInt();
                    if (a > 2 || a < 1) {
                        System.out.println("白內障,看不清,莎普愛思滴眼睛!");
                        break;
                    } else if (a == 1) {
                        File file1 = new File("日志.txt");
                        FileWriter fr = new FileWriter(file1,false);
                        fr.write(" ");
                        fr.close();
                        break;
                    }else if (a == 2){
                        break;
                    }
                }
            }
        }
    }

}

用戶(父類為Person):

package User;

import Book.BorrowBook;
import Book.FindBook;
import Book.ReturnBook;

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class User extends Person {
    //用戶屬性

    private long Uphone;
    private String Upassword;

    public User() {

    }

    public User(String name, String sex, int age, long Uphone, String Upassword) {
        super(name, sex, age);
        this.Uphone = Uphone;
        this.Upassword = Upassword;

    }


    public long getUphone() {
        return Uphone;
    }

    public void setUphone(int uphone) {
        Uphone = uphone;
    }

    public String getUpassword() {
        return Upassword;
    }

    public void setUpassword(String upassword) {
        Upassword = upassword;
    }

    public String toString() {
        return name + "," + Upassword + "," + sex + "," + age + "," + Uphone;
    }

    public void operation(String[] userinf,String operator) throws IOException, ParseException {
        File bookFile = new File("書籍.txt");
        FindBook fb = new FindBook();
        while (true) {
            System.out.println("===============普通用戶操作界面===============");
            System.out.println("1.查詢書籍 2.借閱書籍 3.歸還書籍 4.修改密碼 5.回傳");
            Scanner sc = new Scanner(System.in);
            int j = sc.nextInt();
            if (j < 1 || j > 5) {
                System.out.println("到底能不能行?能不能看明白了再輸!");
            } else if (j == 5) {
                File journal = new File("日志.txt");
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String borrowTime = sdf.format(nowDate);
                FileWriter jfw = new FileWriter(journal, true);
                jfw.write(borrowTime +" "+ operator + "退出了登錄"+"\n");
                jfw.write("--------------------------------");
                jfw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                jfw.close();
                return;
            } else if (j == 1) {//查詢書籍
                fb.findBook(operator);
            } else if (j == 2) {//借閱書籍
                BorrowBook bb = new BorrowBook();
                bb.borrowBook(operator);
            } else if (j == 3) {//歸還書籍
                ReturnBook gbb = new ReturnBook();
                gbb.returnBook(operator);
            } else if (j == 4) {//修改密碼
                String filePath = "用戶資訊.txt";
                User modifyFile = new User();
                File journal = new File("日志.txt");
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String borrowTime = sdf.format(nowDate);
                FileWriter jfw = new FileWriter(journal, true);
                jfw.write(borrowTime +" "+ operator + "修改了密碼"+"\n");
                jfw.write("--------------------------------");
                jfw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                jfw.close();
                System.out.println("請輸入原密碼:");
                String oldString = sc.next();
                //如果輸入的原密碼不正確,無法進行修改,如果正確,才能進行修改
                if (oldString.equals(userinf[1])) {
                    System.out.println("請輸入新密碼:");
                    String newString = sc.next();
                    boolean result = modifyFile.writeFile(filePath, modifyFile.readFileContent(userinf, filePath, oldString, newString));// 修改檔案中密碼

//            如果修改結果為true,進行修改成功提示,否則提示修改失敗
                    if (result == true){
                        System.out.println("修改成功,請重新登錄!");
                        return;
                    }else {
                        System.out.println("修改錯誤,請檢查后重新修改!");
                    }
                } else {
                    System.out.println("輸入錯誤,請檢查后重新進行修改!");
                }
            }

        }
    }

    // 讀檔案
    public String readFileContent(String[] userinf, String filePath, String oldString, String newString) {
        Scanner sc = new Scanner(System.in);
        BufferedReader br = null;
        String line = null;
        StringBuffer bufAll = new StringBuffer();// 保存修改過后的所有內容
        try {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));

            while ((line = br.readLine()) != null) {
                StringBuffer buf = new StringBuffer();
                // 修改內容核心代碼
                String[] userinf2 = line.split(",");
                if (userinf2[0].equals(userinf[0])) {//判斷條件根據自己的要求修改
                    buf.append(line);
                    int indexOf = line.indexOf(oldString);
                    buf.replace(indexOf, indexOf + oldString.length(), newString);// 修改內容
                    buf.append(System.getProperty("line.separator"));// 添加換行
                    bufAll.append(buf);
                } else {
                    buf.append(line);
                    buf.append(System.getProperty("line.separator"));
                    bufAll.append(buf);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (Exception e) {
                    br = null;
                }
            }
        }
        return bufAll.toString();
    }

    // 寫檔案
    public boolean writeFile(String filePath, String content) {
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8"));
            bw.write(content);
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    bw = null;
                }
            }
        }
        return true;
    }
}

Person類:

package User;

public class Person {
    public String name;
    public String sex;
    public int age;

    public Person(){

    }

    public Person(String name,String sex, int age){
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

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

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

    public void setAge(int age){
        this.age = age;
    }
    public int getAge(){
        return age;
    }
}

book類:

package Book;

public class Book {
    private String bookName; //書名
    private String author; //作者
    public double price; //價格
    private String category; //分類
    public String press;//出版社
    private String state; //狀態  true-已借出  false-未借出
    private String borrowName;
    private String borrowTime;


    public Book(){

    }
    public Book(String bookName,String author,double price,String category,String press,String state,String borrowName,String borrowTime){
        this.bookName = bookName;
        this.author = author;
        this.price = price;
        this.category = category;
        this.press = press;
        this.state = state;
        this.borrowName = borrowName;
        this.borrowTime = borrowTime;
    }

    public String getName() {
        return bookName;
    }

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

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getPress() {
        return press;
    }

    public void setPress(String press) {
        this.press = press;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getBorrowName() {
        return borrowName;
    }

    public void setBorrowName(String borrowName) {
        this.borrowName = borrowName;
    }

    public String getBorrowTime() {
        return borrowTime;
    }

    public void setBorrowTime(String borrowTime) {
        this.borrowTime = borrowTime;
    }

    @Override
    public String toString() {
        return bookName +","+author+","+price+","+category+","+press+","+state+","+borrowName+","+borrowTime;
    }
}

下面優先列出管理員的操作功能模塊:
查詢書籍:

package Book;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

public class FindBook {

    Scanner scanner = new Scanner(System.in);
    File bookFile = new File("書籍.txt");

    public void findBook(String operator) throws IOException {
        FileInputStream intput = new FileInputStream(bookFile);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString = null;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }
        boolean flag = false;
        String[] bookinf = new String[8];
        String[] bookinf1 = new String[8];
        System.out.println("==========當前書籍有==========");
        for (String book : list) {
            bookinf1 = book.split(",");
            System.out.print(bookinf1[0] + " ");
        }
        System.out.println(" ");
        System.out.println("請輸入查找的書籍名稱:");
        String bookName = scanner.next();


        for (String user : list) {
            bookinf = user.split(",");
            if (bookName.equals(bookinf[0])) { //判斷書籍是否存在
                flag = true;
                System.out.println("書名:" + bookinf[0] + ",作者:" + bookinf[1] + ",價格:" + bookinf[2] +
                        ",型別:" + bookinf[3] + ",出版社:" + bookinf[4] + ",是否被借出:" + bookinf[5]);
                File journal = new File("日志.txt");
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String borrowTime = sdf.format(nowDate);
                FileWriter jfw = new FileWriter(journal, true);
                jfw.write(borrowTime +" "+ operator + "查看了" + bookinf[0] + "\n");
                jfw.write("--------------------------------");
                jfw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                jfw.close();
                break;
            }
        }
        if (flag == false) {
            System.out.println("沒有查找到該書籍,請重新確認后再進行查找!");
        }

    }

    public void adminFindBook() throws IOException {
        FileInputStream intput = new FileInputStream(bookFile);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString = null;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }
        boolean flag = false;
        String[] bookinf = new String[8];
        String[] bookinf1 = new String[8];
        System.out.println("==========當前書籍有==========");
        for (String book : list) {
            bookinf1 = book.split(",");
            System.out.print(bookinf1[0] + " ");
        }
        System.out.println(" ");
        System.out.println("請輸入查找的書籍名稱:");
        String bookName = scanner.next();

        for (String user : list) {
            bookinf = user.split(",");
            //判斷書籍是否存在
            if (bookName.equals(bookinf[0])) { 
                flag = true;
                System.out.println("書名:" + bookinf[0] + ",作者:" + bookinf[1] + ",價格:" + bookinf[2] + ",型別:" + bookinf[3] +
                        ",出版社:" + bookinf[4] + ",是否被借出:" + bookinf[5] + ",借書人:" + bookinf[6] + ",借出日期:" + bookinf[7]);
                break;
            }
        }
        if (flag == false) {
            System.out.println("沒有查找到該書籍,請重新確認后再進行查找!");
        }

    }
}

添加書籍:

package Book;

import User.User;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class AddBook {
    String[] bookinf = new String[8];

    public void addBook() throws IOException {
        Scanner sc = new Scanner(System.in);
        File file1 = new File("書籍.txt");
        FileInputStream intput = new FileInputStream(file1);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }
        String[] bookinf1 = new String[8];
        System.out.println("==========當前書籍有==========");
        for (String book : list) {
            bookinf1 = book.split(",");
            System.out.print(bookinf1[0] + " ");
        }
        System.out.println(" ");
        System.out.println("請輸入書籍名稱:");
        String bookName = sc.next();
        boolean flag = false;
        for (String user1 : list) {
            bookinf = user1.split(",");
            if (bookName.equals(bookinf[0])) { //判斷書名是否存在
                System.out.println("該書籍名稱已存在,請重新輸入書籍名稱");
                flag = true;
                break;
            }
        }
        if (flag == false) {
            System.out.println("請輸入作者:");
            String author = sc.next();
            double price;
            while (true) {
                System.out.println("請輸入書籍價格:");
                price = sc.nextDouble();
                if (price > 0) {
                    break;
                } else {
                    System.out.println("好家伙,虧死了!");
                }
            }
            System.out.println("請輸入書籍型別:");
            String category = sc.next();
            System.out.println("請輸入書籍的出版社:");
            String press = sc.next();
            String state = "false";
            String borrowName = "無";
            String borrowTime = "null";
            Book book = new Book(bookName, author, price, category, press, state, borrowName, borrowTime);
            file1.createNewFile();
            FileWriter fw = new FileWriter(file1, true);
            fw.write(book.toString());
            fw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
            fw.close();
            System.out.println("恭喜您,添加書籍成功!");
            return;
        }
    }
}

借閱書籍:

package Book;


import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

public class BorrowBook {
    Scanner scanner = new Scanner(System.in);

    public void borrowBook(String operator) throws IOException {
        String filePath = "書籍.txt";
        BorrowBook modifyFile = new BorrowBook();
        File bookFile = new File("書籍.txt");
//        if (bookFile[5] == "false")

        System.out.println("請輸入要借閱的書籍名稱:");
        String bookName = scanner.next();

        //根據書籍名稱查詢到需要修改的書籍資料
        FileInputStream intput = new FileInputStream(bookFile);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString = null;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }
        boolean flag = false;
        String[] bookinf = new String[8];
        for (String user : list) {
            bookinf = user.split(",");
            if (bookName.equals(bookinf[0])) { //判斷書籍是否存在
                flag = true;
                System.out.println("書名:" + bookinf[0] + ",作者:" + bookinf[1] + ",價格:" + bookinf[2] +
                        ",型別:" + bookinf[3] + ",出版社:" + bookinf[4] + ",是否被借出:" + bookinf[5]);
                break;
            }
        }
        if (flag == false) {
            System.out.println("沒有查找到該書籍,請重新確認后再進行查找!");
            return;
        }
        //修改書籍資料后,重新寫入檔案

        if (bookName.equals(bookinf[0]) && bookinf[5].equals("false")) {
            boolean result = modifyFile.writeFile(filePath, modifyFile.readFileContent(bookinf, filePath, "false", "true"));
            // 修改檔案中借閱狀態

            if (result == true) {
                //獲取借書人后寫入“無”
                modifyFile.writeFile(filePath, modifyFile.readFileContent(bookinf, filePath, "無", operator));
                //獲取時間后寫入最后一位
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String borrowTime = sdf.format(nowDate);

                modifyFile.writeFile(filePath, modifyFile.readFileContent(bookinf, filePath, "null", borrowTime));
                System.out.println("借閱成功!");
                System.out.println("借閱時間:" + borrowTime + ",最多可借閱7天,請記得按時歸還!");
                //寫入日志
                File journal = new File("日志.txt");
                FileWriter jfw = new FileWriter(journal, true);
                jfw.write(borrowTime +" "+ operator + "借閱了" + bookinf[0] + "\n");
                jfw.write("--------------------------------");
                jfw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                jfw.close();
                return;
            }
        } else {
            System.out.println("該書已被借出或不存在,請重新查詢后再進行借閱!");
        }

    }

    // 讀檔案
    public String readFileContent(String[] bookinf, String filePath, String oldString, String newString) {
        Scanner sc = new Scanner(System.in);
        BufferedReader br = null;
        String line = null;
        StringBuffer bufAll = new StringBuffer();// 保存修改過后的所有內容
        try {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));
            while ((line = br.readLine()) != null) {
                StringBuffer buf = new StringBuffer();
                // 修改內容核心代碼
                String[] bookinf2 = line.split(",");
                if (bookinf2[0].equals(bookinf[0])) {//判斷條件根據自己的要求修改
                    buf.append(line);
                    int indexOf = line.indexOf(oldString);
                    buf.replace(indexOf, indexOf + oldString.length(), newString);// 修改內容
                    buf.append(System.getProperty("line.separator"));// 添加換行
                    bufAll.append(buf);
                } else {
                    buf.append(line);
                    buf.append(System.getProperty("line.separator"));
                    bufAll.append(buf);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (Exception e) {
                    br = null;
                }
            }
        }
        return bufAll.toString();
    }

    // 寫檔案
    public boolean writeFile(String filePath, String content) {
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8"));
            bw.write(content);
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    bw = null;
                }
            }
        }
        return true;
    }

}




歸還書籍:

package Book;

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

public class ReturnBook {
    Scanner scanner = new Scanner(System.in);

    public void returnBook(String operator) throws IOException, ParseException {
        String filePath = "書籍.txt";
        ReturnBook modifyFile = new ReturnBook();
        File bookFile = new File("書籍.txt");

        System.out.println("請輸入要歸還的書籍名稱:");
        String bookName = scanner.next();

        //根據書籍名稱查詢到需要修改的書籍資料
        FileInputStream intput = new FileInputStream(bookFile);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString = null;
        List<String> list = new ArrayList<>();

        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);

        }
        int flag = 0;
        String[] bookinf = new String[8];
        for (String user : list) {
            bookinf = user.split(",");
            if (bookName.equals(bookinf[0]) && operator.equals(bookinf[6])) {
                //判斷書籍是否存在,且為本人所借出
                //若屬實則輸出書籍完整資訊
                flag = 1;
                System.out.println("書名:" + bookinf[0] + ",作者:" + bookinf[1] + ",價格:" + bookinf[2] + ",型別:" + bookinf[3] +
                        ",出版社:" + bookinf[4] + ",是否被借出:" + bookinf[5] + ",借書人:" + bookinf[6] + ",借出日期:" + bookinf[7]);
                //判斷是否超時,超時需付罰金
                long charge = 0;//兩個時間相差的毫秒數
                long charge1 = 0;//兩個時間相差的毫秒數
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String returnTime = sdf.format(nowDate);//獲取歸還時間
                Date d1 = sdf.parse(bookinf[7]);//借出時間
                Date d2 = sdf.parse(returnTime);//歸還時間
                charge = (d2.getTime() - d1.getTime()) / (24 * 60 * 60 * 1000);
                charge1 = (d2.getTime() - d1.getTime()) / (1000);
                if (charge1 <= 7) {
                    System.out.println("該書籍被您借出" + charge + "天"+charge1+"秒,"+"感謝您規范用書!");
                } else if (charge1 > 7) {
                    System.out.println("該書籍被您借出" + charge + "天"+charge1+"秒,"+"您已逾期" + (charge1 - 7) + "天,需交罰金:" + (charge1 - 7) * 5 + "元,謝謝配合!");
                }
                break;
            } else if (bookName.equals(bookinf[0]) && !operator.equals(bookinf[6]) && bookinf[5].equals("true")) {
                //判斷書籍是否存在,且為本人所借出
                //若存在該書籍且被借出,但不是本人所借出,只輸出該書籍基本資訊
                flag = 2;
                System.out.println("書名:" + bookinf[0] + ",作者:" + bookinf[1] + ",價格:" + bookinf[2] +
                        ",型別:" + bookinf[3] + ",出版社:" + bookinf[4] + ",是否被借出:" + bookinf[5]);
                break;
            } else if (bookName.equals(bookinf[0]) && bookinf[5].equals("false")) {
                //判斷書籍是否存在,且為本人所借出
                //若存在該書籍但并未被借出,只輸出該書籍基本資訊
                flag = 3;
                System.out.println("書名:" + bookinf[0] + ",作者:" + bookinf[1] + ",價格:" + bookinf[2] +
                        ",型別:" + bookinf[3] + ",出版社:" + bookinf[4] + ",是否被借出:" + bookinf[5]);
                break;
            }
        }
        if (flag == 0) {
            System.out.println("沒有查找到該書籍,請重新確認后再進行查找!");
        } else if (flag == 2) {
            System.out.println("該書不是由您所借出,請查證后再輸入歸還的書籍!");
        } else if (flag == 3) {
            System.out.println("該書并未被借出,請查證后再輸入歸還的書籍!");
        }
        //修改書籍資料后,重新寫入檔案

        else if (flag == 1) {
            if (bookName.equals(bookinf[0]) && bookinf[5].equals("true") && operator.equals(bookinf[6])) {
                modifyFile.writeFile(filePath, modifyFile.readFileContent(bookinf, filePath, "true", "false"));
                // 修改檔案中借閱狀態

                modifyFile.writeFile(filePath, modifyFile.readFileContent(bookinf, filePath, operator, "無"));
                modifyFile.writeFile(filePath, modifyFile.readFileContent(bookinf, filePath, bookinf[7], "null"));
                File journal = new File("日志.txt");
                Date nowDate = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                String borrowTime = sdf.format(nowDate);
                FileWriter jfw = new FileWriter(journal, true);
                jfw.write(borrowTime +" "+ operator + "歸還了" + bookinf[0] + "\n");
                jfw.write("--------------------------------");
                jfw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                jfw.close();
                System.out.println("歸還成功!");
                return;

            }
        }
    }

    // 讀檔案
    public String readFileContent(String[] bookinf, String filePath, String oldString, String newString) {
        Scanner sc = new Scanner(System.in);
        BufferedReader br = null;
        String line = null;
        StringBuffer bufAll = new StringBuffer();// 保存修改過后的所有內容
        try {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), "UTF-8"));
//            System.out.println("請確認您的用戶名:");
//            String username = sc.next();
            while ((line = br.readLine()) != null) {
                StringBuffer buf = new StringBuffer();
                // 修改內容核心代碼
                String[] bookinf2 = line.split(",");
                if (bookinf2[0].equals(bookinf[0])) {//判斷條件根據自己的要求修改
                    buf.append(line);
                    int indexOf = line.indexOf(oldString);
                    buf.replace(indexOf, indexOf + oldString.length(), newString);// 修改內容
                    buf.append(System.getProperty("line.separator"));// 添加換行
                    bufAll.append(buf);
                } else {
                    buf.append(line);
                    buf.append(System.getProperty("line.separator"));
                    bufAll.append(buf);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (Exception e) {
                    br = null;
                }
            }
        }
        return bufAll.toString();
    }

    // 寫檔案
    public boolean writeFile(String filePath, String content) {
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8"));
            bw.write(content);
            bw.flush();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    bw = null;
                }
            }
        }
        return true;
    }
}

洗掉書籍:

package Book;

import User.DeleteUser;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class DeleteBook {
    private String bookDelete;
    String[] bookinf = new String[8];
    String[] bookinf1 = new String[8];
    String[] bookinf2 = new String[8];
    String[] bookinf3 = new String[8];

    public void deleteBook() throws IOException {
        File file = new File("書籍.txt");
        FileInputStream intput = new FileInputStream(file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }
        System.out.println("==========當前書籍有==========");
        for (String book : list) {
            bookinf = book.split(",");
            System.out.print(bookinf[0] + " ");
        }
        System.out.println("");
        System.out.println("請輸入要洗掉的書籍名稱:");
        Scanner scanner = new Scanner(System.in);
        bookDelete = scanner.next();
        boolean bookflag = false;//書名是否存在的標志量; true--存在  false--不存在
        boolean bookflag1 = false;
        for (String book : list) {
            bookinf1 = book.split(",");
            if (bookDelete.equals(bookinf1[0])) { //判斷書名是否存在
                bookflag = true;
                break;
            }
        }
        if (bookflag == true) {
            for (String book : list) {
                bookinf3 = book.split(",");
                if (bookDelete.equals(bookinf3[0]) && bookinf3[5].equals("false")) {
                    bookflag1 = true;
                    list.remove(book);
                    FileWriter fd = new FileWriter(file, false);
                    fd.write("");
                    fd.close();
                    break;
                } else if (bookDelete.equals(bookinf3[0]) && bookinf3[5].equals("true")) {
                    System.out.println("此書已經被借出,請用戶歸還書后再進行洗掉操作!");
                    bookflag1 = false;
                    break;
                }
            }
        }else{
            System.out.println("無法找到該書籍,請重新確認后再進行操作!");
            return;
        }
        if (bookflag1 == true) {
            for (String book : list) {
                bookinf2 = book.split(",");
                FileWriter fw = new FileWriter(file, true);
                fw.write(bookinf2[0] + "," + bookinf2[1] + "," + bookinf2[2] + "," + bookinf2[3] +
                        "," + bookinf2[4] + "," + bookinf2[5] + "," + bookinf2[6] + "," + bookinf2[7]);
                fw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                fw.close();
            }
            System.out.println("洗掉成功!");
        }

    }


    public static void main(String[] args) throws IOException {
        DeleteBook db = new DeleteBook();
        db.deleteBook();
    }
}

添加用戶:

package User;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

@SuppressWarnings({"all"})
public class AddUser {
    String[] userinf = new String[5];

    public void addUser() throws IOException {
        Scanner sc = new Scanner(System.in);
        File file = new File("用戶資訊.txt");
        FileInputStream intput = new FileInputStream(file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }
        System.out.println("請輸入要添加的用戶名:");
        String name = sc.next();
        //查找是否有同名用戶
        boolean flag = false;
        for (String user1 : list) {
            userinf = user1.split(",");
            if (name.equals(userinf[0])) { //判斷用戶名是否存在
                System.out.println("該用戶名已存在,請重新擬取名稱");
                flag = true;
                break;
            }
        }
        if (flag == false) {
            System.out.println("請設定該用戶的密碼:");
            String password = sc.next();
            String sex;
            while (true) {
                System.out.println("請輸入該用戶的性別:");
                sex = sc.next();
                if (sex.equals("男") || sex.equals("女")) {
                    break;
                } else {
                    System.out.println("別鬧!認真點,輸入正確的性別!");
                }
            }
            int age;
            while (true) {
                System.out.println("請輸入該用戶的年齡:");
                age = sc.nextInt();
                if (age < 10) {
                    System.out.println("身為管理員,你擱這兒干啥捏,連個年齡都輸不對!");
                } else {
                    break;
                }
            }

            long phone;
            while (true) {
                System.out.println("請輸入該用戶的電話號碼:");
                phone = sc.nextInt();
                if (phone < 0) {
                    System.out.println("身為管理員,你擱這兒干啥捏,連個電話號碼都輸不對!");
                } else {
                    break;
                }
            }
            User user = new User(name, sex, age, phone, password);
            file.createNewFile();
            FileWriter fw = new FileWriter(file, true);
            fw.write(user.toString());
            fw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
            fw.close();
            System.out.println("成功添加用戶:" + name);
            return;
        }
    }
}


洗掉用戶:

package User;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class DeleteUser {
    private String userDelete;
    String[] userinf = new String[5];
    String[] userinf1 = new String[5];
    String[] userinf2 = new String[5];
    String[] bookinf = new String[8];

    public void deleteUser() throws IOException {
        File file = new File("用戶資訊.txt");
        FileInputStream intput = new FileInputStream(file);
        BufferedReader reader = new BufferedReader(new InputStreamReader(intput));
        String tempString;
        List<String> list = new ArrayList<>();
        while ((tempString = reader.readLine()) != null) {
            list.add(tempString);
        }

        System.out.println("==========當前用戶有==========");
        for (String user : list) {
            userinf = user.split(",");
            System.out.print(userinf[0] + " ");
        }
        System.out.println("");
        System.out.println("請輸入要洗掉資訊的用戶名:");
        Scanner scanner = new Scanner(System.in);
        userDelete = scanner.next();
        File file1 = new File("書籍.txt");
        FileInputStream intput1 = new FileInputStream(file1);
        BufferedReader reader1 = new BufferedReader(new InputStreamReader(intput1));
        List<String> list1 = new ArrayList<>();
        String tempString1;
        while ((tempString1 = reader1.readLine()) != null) {
            list1.add(tempString1);
        }
        boolean flag = false;
        boolean flag1 = false;
        for (String book : list1) {
            bookinf = book.split(",");
            if (userDelete.equals(bookinf[6])) {
                System.out.println("此用戶還有書籍尚未歸還,請勿洗掉!");
                flag = true;
                break;
            }
        }
        if (flag == false) {
            for (String user : list) {
                userinf1 = user.split(",");
                if (userDelete.equals(userinf1[0])) {//判斷用戶名是否存在
                    flag1 = true;
                    list.remove(user);
                    FileWriter fd = new FileWriter(file, false);
                    fd.write("");
                    fd.close();
                    break;
                }
            }
        }

        if (flag1 == true) {
            for (String user : list) {
                userinf2 = user.split(",");
                FileWriter fw = new FileWriter(file, true);
                fw.write(userinf2[0] + "," + userinf2[1] + "," + userinf2[2] + "," + userinf2[3] + "," + userinf2[4]);
                fw.write(System.getProperty("line.separator"));//在段落后添加一個換行符
                fw.close();
            }
            System.out.println("洗掉成功!");
        } else if (flag == false && flag1 == false) {
            System.out.println("無法找到該用戶,請重新確認后再進行操作!");
            return;
        }
    }
}

查看日志的模塊在admin類中有顯示;

總結:
本次代碼實踐專案中隨未使用資料庫(是因為沒學呢!),但是通過I/O流把書籍和用戶資訊以及用戶操作的記錄都保存到了檔案中,加深了自己對于I/O流及其使用方法的理解,本代碼中通過對Date類的方法使用,獲取了當下時間,并記錄下來,更加清晰地知道了用戶借閱圖書與歸還圖書的時間,為管理員更好地管理用戶提供了便捷,
總的來說,這次專案實踐是自己受益良多,對于知識的掌握更加有了一個清晰地認知,
此次代碼還有許多不完善的地方,還請小可愛們多多指出,共同進步!

一起加油!!!

在這里插入圖片描述

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/278576.html

標籤:其他

上一篇:面試讓HR都能聽懂的MySQL鎖機制,歡聲笑語中搞懂MySQL鎖

下一篇:一篇文章弄懂單鏈表(大話資料結構)

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 面試突擊第一季,第二季,第三季

    第一季必考 https://www.bilibili.com/video/BV1FE411y79Y?from=search&seid=15921726601957489746 第二季分布式 https://www.bilibili.com/video/BV13f4y127ee/?spm_id_fro ......

    uj5u.com 2020-09-10 05:35:24 more
  • 第三單元作業總結

    1.前言 這應該是本學期最后一次寫作業總結了吧。總體來說,對作業的節奏也差不多掌握了,作業做起來的效率也更高了。雖然和之前的作業一樣,作業中都要用到新的知識,但是相比之前,更加懂得了如何利用工具以及資料。雖然之間卡過殼,但總體而言,這幾次作業還算完成的比較好。 2.作業程序總結 相比前兩個單元,此單 ......

    uj5u.com 2020-09-10 05:35:41 more
  • 北航OO(2020)第四單元博客作業暨課程總結博客

    北航OO(2020)第四單元博客作業暨課程總結博客 本單元作業的架構設計 在本單元中,由于UML圖具有比較清晰的樹形結構,因此我對其中需要進行查詢操作的元素進行了包裝,在樹的父節點中存盤所有孩子的參考。考慮到性能問題,我采用了快取機制,一次查詢后盡可能快取已經遍歷過的資訊,以減少遍歷次數。 本單元我 ......

    uj5u.com 2020-09-10 05:35:48 more
  • BUAA_OO_第四單元

    一、UML決議器設計 ? 先看下題目:第四單元實作一個基于JDK 8帶有效性檢查的UML(Unified Modeling Language)類圖,順序圖,狀態圖分析器 MyUmlInteraction,實際上我們要建立一個有向圖模型,UML中的物件(元素)可能與同級元素連接,也可與低級元素相連形成 ......

    uj5u.com 2020-09-10 05:35:54 more
  • 6.1邏輯運算子

    邏輯運算子 1. && 短路與 運算式1 && 運算式2 01.運算式1為true并且運算式2也為true 整體回傳為true 02.運算式1為false,將不會執行運算式2 整體回傳為false 03.只要有一個運算式為false 整體回傳為false 2. || 短路或 運算式1 || 運算式2 ......

    uj5u.com 2020-09-10 05:35:56 more
  • BUAAOO 第四單元 & 課程總結

    1. 第四單元:StarUml檔案決議 本單元采用了圖模型決議UML。 UML檔案可以抽象為圖、子圖、邊的邏輯結構。 在實作中,圖的節點包括類、介面、屬性,子圖包括狀態圖、順序圖等。 采用了三次遍歷UML元素的方法建圖,第一遍遍歷建點,第二、三次遍歷設定屬性、連邊,實作圖物件的初始化。這里借鑒了一些 ......

    uj5u.com 2020-09-10 05:36:06 more
  • 談談我對C# 多型的理解

    面向物件三要素:封裝、繼承、多型。 封裝和繼承,這兩個比較好理解,但要理解多型的話,可就稍微有點難度了。今天,我們就來講講多型的理解。 我們應該經常會看到面試題目:請談談對多型的理解。 其實呢,多型非常簡單,就一句話:呼叫同一種方法產生了不同的結果。 具體實作方式有三種。 一、多載 多載很簡單。 p ......

    uj5u.com 2020-09-10 05:36:09 more
  • Python 資料驅動工具:DDT

    背景 python 的unittest 沒有自帶資料驅動功能。 所以如果使用unittest,同時又想使用資料驅動,那么就可以使用DDT來完成。 DDT是 “Data-Driven Tests”的縮寫。 資料:http://ddt.readthedocs.io/en/latest/ 使用方法 dd. ......

    uj5u.com 2020-09-10 05:36:13 more
  • Python里面的xlrd模塊詳解

    那我就一下面積個問題對xlrd模塊進行學習一下: 1.什么是xlrd模塊? 2.為什么使用xlrd模塊? 3.怎樣使用xlrd模塊? 1.什么是xlrd模塊? ?python操作excel主要用到xlrd和xlwt這兩個庫,即xlrd是讀excel,xlwt是寫excel的庫。 今天就先來說一下xl ......

    uj5u.com 2020-09-10 05:36:28 more
  • 當我們創建HashMap時,底層到底做了什么?

    jdk1.7中的底層實作程序(底層基于陣列+鏈表) 在我們new HashMap()時,底層創建了默認長度為16的一維陣列Entry[ ] table。當我們呼叫map.put(key1,value1)方法向HashMap里添加資料的時候: 首先,呼叫key1所在類的hashCode()計算key1 ......

    uj5u.com 2020-09-10 05:36:38 more
最新发布
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:20:47 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:20:25 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:20:17 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:20:10 more
  • 【中介者設計模式詳解】C/Java/JS/Go/Python/TS不同語言實作

    * 中介者模式是一種行為型設計模式,它可以用來減少類之間的直接依賴關系,
    * 將物件之間的通信封裝到一個中介者物件中,從而使得各個物件之間的關系更加松散。
    * 在中介者模式中,物件之間不再直接相互互動,而是通過中介者來中轉訊息。 ......

    uj5u.com 2023-04-20 08:19:44 more
  • 露天煤礦現場調研和交流案例分享

    他們集團的資訊化公司及研究院在一個礦區正在做智能礦山的統一平臺的 試點,專案投資大概1億,包括了礦山的各方面的內容,顯示得我們這次交流有點多余。他們2年前開始做智能礦山的規劃,有很多煤礦行業專家的加持,他們的描述是非常完美,但是去年底應該上線的平臺,現在還沒有看到影子。他們確實有很多場景需求,但是被... ......

    uj5u.com 2023-04-20 08:19:07 more
  • 《社區人員管理》實戰案例設計&個人案例分享

    設計是一個讓人夢想成真程序,開始編碼、測驗、除錯之前進行需求分析和架構設計,才能保證關鍵方面都做正確 ......

    uj5u.com 2023-04-20 08:18:57 more
  • 軟體架構生態化-多角色交付的探索實踐

    作為一個技術架構師,不僅僅要緊跟行業技術趨勢,還要結合研發團隊現狀及痛點,探索新的交付方案。在日常中,你是否遇到如下問題 “ 業務需求排期長研發是瓶頸;非研發角色感受不到研發技改提效的變化;引入ISV 團隊又擔心質量和安全,培訓周期長“等等,基于此我們探索了一種新的技術體系及交付方案來解決如上問題。 ......

    uj5u.com 2023-04-20 08:18:49 more
  • 05單件模式

    #經典的單件模式 public class Singleton { private static Singleton uniqueInstance; //一個靜態變數持有Singleton類的唯一實體。 // 其他有用的實體變數寫在這里 //構造器宣告為私有,只有Singleton可以實體化這個類! ......

    uj5u.com 2023-04-19 08:42:51 more
  • 【架構與設計】常見微服務分層架構的區別和落地實踐

    軟體工程的方方面面都遵循一個最基本的道理:沒有銀彈,架構分層模型更是如此,每一種都有各自優缺點,所以請根據不同的業務場景,并遵循簡單、可演進這兩個重要的架構原則選擇合適的架構分層模型即可。 ......

    uj5u.com 2023-04-19 08:42:41 more