圖書館管理代碼java 圖書館管理系統(tǒng)代碼java

求一個java圖書管理系統(tǒng)代碼,不需要圖形化,命令行就可以,只要求實現(xiàn)導(dǎo)入圖書,查詢,刪除

import?java.io.BufferedReader;

創(chuàng)新互聯(lián)公司專注網(wǎng)站設(shè)計,以設(shè)計驅(qū)動企業(yè)價值的持續(xù)增長,網(wǎng)站,看似簡單卻每一個企業(yè)都需要——設(shè)計,看似簡潔卻是每一位設(shè)計師的心血 十余年來,我們只專注做網(wǎng)站。認(rèn)真對待每一個客戶,我們不用口頭的語言來吹擂我們的優(yōu)秀,近千家的成功案例見證著我們的成長。

import?java.io.File;

import?java.io.FileReader;

import?java.util.ArrayList;

import?java.util.List;

import?java.util.Scanner;

public?class?BookWork?{

static?ListBook?data;

private?static?Scanner?input;

public?static?void?main(String[]?args)?{

if?(!initBook("d:/book.txt"))?{

System.out.println("初始圖書列表失敗?..");

return;

}

input?=?new?Scanner(System.in);

while?(true)?{

try?{

System.out.println("請輸入操作:");

System.out.println("1.找書??2.刪除圖書?3.退出");

int?number?=?Integer.parseInt(input.next());

if?(number?==?1)?{

findBook();

}?else?if?(number?==?2)?{

delBook();

}?else?if?(number?==?3)?{

System.out.println("退出");

break;

}?else?{

System.out.println("這個不是我要的...重來...");

System.out.println();

}

}?catch?(Exception?e)?{

e.printStackTrace();

System.out.println("這個不是我要的...重來...");

System.out.println();

}

}

}

private?static?void?delBook()?{

System.out.println("請輸入要刪除的書名或編號:");

String?key?=?input.next();

if?(key?!=?null??!key.equals(""))?{

for?(Book?book?:?data)?{

if?(book.number.equals(key)?||?book.name.contains(key))?{

data.remove(book);

System.out.println("?圖書?"?+?book.toString()?+?"?已刪除");

return;

}

}

}

System.out.println("沒有您要刪除的");

}

private?static?void?findBook()?{

System.out.println("請輸入要查找的書名或編號:");

String?key?=?input.next();

if?(key?!=?null??!key.equals(""))?{

for?(Book?book?:?data)?{

if?(book.number.equals(key)?||?book.name.contains(key))?{

System.out.println("找到了?圖書?"?+?book.toString());

return;

}

}

}

System.out.println("沒有您要找的");

}

private?static?boolean?initBook(String?string)?{

try?{

System.out.println("圖書導(dǎo)入中...");

System.out.println("列表文件?--?"?+?string);

File?file?=?new?File(string);

if?(!file.exists())?{

return?false;

}

data?=?new?ArrayListBook();

BufferedReader?bufferedReader?=?new?BufferedReader(new?FileReader(file));

String?line?=?"";

while?((line?=?bufferedReader.readLine())?!=?null)?{

String[]?strings?=?line.split(",");

Book?b?=?new?Book(strings[0],?strings[1]);

data.add(b);

System.out.println("導(dǎo)入"?+?b.toString());

}

}?catch?(Exception?e)?{

e.printStackTrace();

return?false;

}

return?true;

}

public?static?class?Book?{

String?number;

String?name;

public?Book(String?number,?String?name)?{

super();

this.number?=?number;

this.name?=?name;

}

@Override

public?String?toString()?{

return?"Book?[編碼:"?+?number?+?",?名稱:"?+?name?+?"]";

}

}

}

001,金瓶梅

002,雜事秘辛

003,飛燕外傳

004,控鶴監(jiān)秘記

005,漢宮春色

圖書館管理系統(tǒng)java怎么做

先考慮軟件環(huán)境問題,確定好開發(fā)工具和數(shù)據(jù)庫。圖書館管理系統(tǒng),我的理解就是一個檔案管理而已,數(shù)據(jù)庫用sql

server;然后最好設(shè)計一個數(shù)據(jù)庫模型和功能模型,把你的系統(tǒng)的主要功能和需要的數(shù)據(jù)庫表有一個雛形。你需要用戶登錄,則至少有一個用戶管理的功能,如果更復(fù)雜一點,應(yīng)該有一個權(quán)限管理,日志管理。如果還要分角色,則需要角色管理。然后肯定得有一個圖書入庫,圖書借出,圖書歸還等等功能;然后就是詳細(xì)設(shè)計了,每個功能模塊大概需要哪些更詳細(xì)的功能點;做好前面幾部非常關(guān)鍵,不然后面才發(fā)現(xiàn)設(shè)計跟需求出現(xiàn)大的偏差,后果就非常嚴(yán)重了;后面就是代碼編寫測試,純技術(shù)問題,一般問題不大。

用java編寫一個 圖書館圖書借閱管理系統(tǒng)

---------------------------------------------------

給你修改了三個地方:

1.borrowBooks方法中,將System.out.println("你要借嗎?"); 改為:

System.out.println("你要借嗎?輸入1表示借,其他數(shù)字表示不借。");

保證輸入的時候輸入的數(shù)字,否則會報出異常。

2.borrowBooks方法中,將self[score] = all[9]; 改為:self[score] = all[i];

如果是all[9],那么就始終是最后一本書籍信息了。

3.have方法中,你是想將所借的書籍信息都打印出來。修改的比較多,下面注釋代碼是原來的。

void have(Books[] self) {

// for (int i = 0; i 2; i++) {

// self[i].showBookInfo();

// }

for (int i = 0; i 3; i++) {

if(self[i]!=null)

self[i].showBookInfo();

}

}

****************** 附上所有代碼:*************************

import java.util.Scanner;

public class TestBook {

public static void main(String[] args) {

Books all[] = new Books[10];

Books self[] = new Books[3];

all[0] = new Books("java", 1, "12345", "tom", 34.0f, "人民出版社");

all[1] = new Books("c", 2, "12346", "tnn", 31.0f, "人民出版社");

all[2] = new Books("c++", 3, "12445", "mm", 35.0f, "人民出版社");

all[3] = new Books("c#", 4, "12365", "tt", 38.0f, "人民出版社");

all[4] = new Books("j2se", 5, "13345", "tosm", 31.1f, "人民出版社");

all[5] = new Books("j2ee", 6, "18345", "ttm", 32.0f, "人民出版社");

all[6] = new Books("jsp", 7, "12335", "cc", 33.0f, "人民出版社");

all[7] = new Books("net", 8, "12341", "bb", 36.0f, "人民出版社");

all[8] = new Books("ip", 9, "12343", "aa", 37.0f, "人民出版社");

all[9] = new Books("tcp", 10, "22345", "jj", 39.0f, "人民出版社");

Readers r = new Readers("xiaoming", 101, "1", 3);

r.searchAllBooks(all);

r.borrowBooks(all, self);

r.have(self);

r.give(all, self);

}

}

class Readers {

Scanner scan = new Scanner(System.in);

String names;

int nums;

String classes;

int grade;

int score = 0;

// Books self[]=new Books[3];

Readers(String n, int u, String c, int g) {

names = n;

nums = u;

classes = c;

grade = g;

}

void searchAllBooks(Books[] all) {// 查書

for (int i = 0; i 10; i++)

all[i].showBookInfo();

// self[score]=all[0];

}

void give(Books[] all, Books[] self) {// 還書

System.out.println("請輸入您要還的書的書號");

int n = scan.nextInt();

for (int i = 0; i 10; i++) {

if (n == all[i].num) {

for (int j = 0; j 3; j++) {

if (self[j] == all[i]) {

self[j] = null;

System.out.println("還書成功");

}

}

}

}

}

void have(Books[] self) {

// for (int i = 0; i 2; i++) {

// self[i].showBookInfo();

// }

for (int i = 0; i 3; i++) {

if(self[i]!=null)

self[i].showBookInfo();

}

}

void giveMoney() {

}

void borrowBooks(Books[] all, Books[] self) {

System.out.println("請輸入您要查找的書名:");

String n = scan.next();

int i;

for (i = 0; i 10; i++) {

if (n.equals(all[i].name)) {

all[i].showBookInfo();

break;

}

}

//System.out.println("你要借嗎?");

System.out.println("你要借嗎?輸入1表示借,其他數(shù)字表示不借。");

int j;

j = scan.nextInt();

if (j == 1) {

System.out.println("借閱成功");

//self[score] = all[9];

self[score] = all[i];

score += 1;

}

if (score 4) {

System.out.println("您還可以借閱" + (3 - score) + "本");

} else {

System.out.println("對不起,一個人只能借3本");

}

}

}

class Books {

String name;

int num;

String ISBN;

String writer;

float price;

String publisher;

Books(String n, int u, String i, String w, float p, String l) {

name = n;

num = u;

ISBN = i;

writer = w;

price = p;

publisher = l;

}

void showBookInfo() {

System.out.println("**************************");

System.out.println("書名:" + name);

System.out.println("索書號:" + num);

System.out.println("ISBN號:" + ISBN);

System.out.println("價格:" + price);

System.out.println("出版社:" + publisher);

System.out.println("**************************");

}

}

----------------------------------------------------

java圖書管理系統(tǒng)代碼

最近好多人要這份源碼啊感覺..有建表腳本..使用mysql數(shù)據(jù)庫..建表之后就可以直接運行了.

當(dāng)前文章:圖書館管理代碼java 圖書館管理系統(tǒng)代碼java
文章來源:http://muchs.cn/article32/dospopc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、網(wǎng)站營銷、云服務(wù)器面包屑導(dǎo)航、微信小程序、App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站