真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

包含教室借閱系統(tǒng)java代碼的詞條

Java編寫圖書管理系統(tǒng),使用XML存儲

import?java.io.File;

成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站建設(shè)、做網(wǎng)站、雙江網(wǎng)絡(luò)推廣、微信平臺小程序開發(fā)、雙江網(wǎng)絡(luò)營銷、雙江企業(yè)策劃、雙江品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供雙江建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:www.cdcxhl.com

import?java.io.FileOutputStream;

import?java.util.ArrayList;

import?java.util.List;

import?java.util.Scanner;

import?org.dom4j.Document;

import?org.dom4j.DocumentHelper;

import?org.dom4j.Element;

import?org.dom4j.io.OutputFormat;

import?org.dom4j.io.SAXReader;

import?org.dom4j.io.XMLWriter;

public?class?Book?{

private?int?no;

private?String?name;

private?double?value;

public?Book()?{

}

public?Book(int?no,?String?name,?double?value)?{

this.no?=?no;

this.name?=?name;

this.value?=?value;

}

public?double?getValue()?{

return?value;

}

public?void?setValue(double?value)?{

this.value?=?value;

}

public?String?getName()?{

return?name;

}

public?void?setName(String?name)?{

this.name?=?name;

}

public?int?getNo()?{

return?no;

}

public?void?setNo(int?no)?{

this.no?=?no;

}

}

class?BookList?{

private?ListBook?bookList;

public?BookList()?{

bookList?=?readXML();

}

public?long?getCount()?{

return?bookList.size();

}

public?ListBook?getBookList()?{

return?bookList;

}

public?void?setBookList(ListBook?bookList)?{

this.bookList?=?bookList;

}

public?void?add(Book?book)?{

bookList.add(book);

}

public?boolean?delete(String?name)?{

Book?book?=?query(name);

return?bookList.remove(book);

}

public?void?update(Book?bookBefore,?Book?bookAfter)?{

bookList.remove(bookBefore);

add(bookAfter);

}

public?Book?query(String?name)?{

Book?temp?=?null;

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

if?(book.getName().equals(name))?{

temp?=?book;

}

}

return?temp;

}

public?synchronized?void?writeXmlDocument(Book?book)?{

try?{

File?file?=?new?File("D:\\book.xml");

Document?document?=?null;

Element?root?=?null;

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

//?新建student.xml文件并新增內(nèi)容

document?=?DocumentHelper.createDocument();

root?=?document.addElement("Books");//添加根節(jié)點(diǎn)???

}?else?{

SAXReader?saxReader?=?new?SAXReader();

document?=?saxReader.read(file);

root?=?document.getRootElement();//獲得根節(jié)點(diǎn)

}

Element?secondRoot?=?root.addElement("Book");//二級節(jié)點(diǎn)???

//為二級節(jié)點(diǎn)添加屬性,屬性值為對應(yīng)屬性的值???

secondRoot.addElement("no").setText(book.getNo()?+?"");

secondRoot.addElement("name").setText(book.getName()?+?"");

secondRoot.addElement("value").setText(book.getValue()?+?"");

OutputFormat?format?=?OutputFormat.createPrettyPrint();

format.setEncoding("GBK");

XMLWriter?writer?=?new?XMLWriter(new?FileOutputStream("D:\\book.xml"),?format);

writer.write(document);

writer.close();

document.clearContent();

}?catch?(Exception?e)?{

e.printStackTrace();

}

}

public?synchronized?ListBook?readXML()?{

ListBook?list?=?new?ArrayListBook();//創(chuàng)建list集合???

File?file?=?null;

try?{

file?=?new?File("D:\\book.xml");//讀取文件???

if?(file.exists())?{

SAXReader?saxReader?=?new?SAXReader();

Document?document?=?saxReader.read(file);

List?nodeList?=?document.selectNodes("Books/Book");

for?(int?i?=?0;?i??nodeList.size();?i++)?{

Element?el?=?(Element)?nodeList.get(i);

Book?book?=?new?Book();

book.setNo(Integer.parseInt(el.elementText("no")));

book.setName(el.elementText("name"));

book.setValue(Double.parseDouble(el.elementText("value")));

list.add(book);

}

}

}?catch?(Exception?e)?{

e.printStackTrace();

}

return?list;

}

}

class?Test?{

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

BookList?bl?=?new?BookList();

boolean?bBreak?=?true;

while?(bBreak)?{

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

System.out.println("1:添加?2:刪除?3:修改?4:查詢?5:書籍統(tǒng)計(jì)?6:退出");

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

int?code?=?sc.nextInt();

if?(code?==?1)?{

System.out.println("請輸入編號");

int?no?=?sc.nextInt();

System.out.println("請輸入書名");

String?name?=?sc.next();

System.out.println("請輸入售價(jià)");

double?value?=?sc.nextDouble();

Book?book?=?new?Book(no,?name,?value);

bl.add(book);

bl.writeXmlDocument(book);

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

System.out.println("請輸入要刪除的書籍名");

String?name?=?sc.next();

if?(bl.delete(name))?{

System.out.println("刪除成功");

}?else?{

System.out.println("書籍不存在");

}

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

System.out.println("請輸入要修改的書籍名");

String?name?=?sc.next();

Book?bookBefore?=?bl.query(name);

System.out.println("請輸入新的編號");

int?newNo?=?sc.nextInt();

System.out.println("請輸入新的書名");

String?newName?=?sc.next();

System.out.println("請輸入新的售價(jià)");

double?value?=?sc.nextDouble();

Book?bookAfter?=?new?Book(newNo,?newName,?value);

bl.update(bookBefore,?bookAfter);

}?else?if?(code?==?4)?{

System.out.println("請輸入要查詢的書籍名");

String?name?=?sc.next();

Book?book?=?bl.query(name);

System.out.println("編號:"?+?book.getNo()?+?"?書名:"?+?book.getName()?+?"?售價(jià):"?+?book.getValue());

}?else?if?(code?==?5)?{

ListBook?list?=?bl.getBookList();

System.out.println("總書籍?dāng)?shù):"?+?bl.getCount());

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

System.out.println("編號:"?+?book.getNo()?+?"?書名:"?+?book.getName()?+?"?售價(jià):"?+?book.getValue());

}

}?else?if?(code?==?6)?{

bBreak?=?false;

}

}

}

}

jar 包 ?dom4j.jar ?jaxen-1.1.4.jar

JAVA對圖書館借閱書籍情況編程

首先這個(gè)問題涉及到三個(gè)對象和一個(gè)動作,即圖書對象,學(xué)生對象和借書信息的對象,和完成“借書”的動作,圖書對象又可以包含圖書編號,書名,作者,出版社,出版日期等等,學(xué)生對象包含學(xué)生編號,姓名,性別,班級,系別等等。借書信息對象包含圖書編號,學(xué)生編號,借書時(shí)間,借書數(shù)目等等

寫好這三個(gè)類,然后分別new一個(gè)圖書和學(xué)生的對象實(shí)例,

接著寫一個(gè)借書動作過程的方法,將圖書對象和學(xué)生對象的屬性保存到借書信息的對象中....代碼略

求java編程源代碼,關(guān)于圖書借閱系統(tǒng)的,

eess:跪求運(yùn)用java實(shí)現(xiàn)圖書借閱系統(tǒng)的設(shè)計(jì)源代碼

為獲取幫助,你需要告訴我們合法的電子郵件地址*

您還能借助baiduhi聯(lián)系我們或qq:六伍柒幺伍六幺伍

('幺'讀

yao

一聲)

針對本題目

我們能提供一套與需求相匹配的源代碼

es:\bd451e98b28557d0a0ef65c37d6877a8

eess:跪求運(yùn)用java實(shí)現(xiàn)圖書借閱系統(tǒng)的設(shè)計(jì)源代碼

交易提醒:預(yù)付訂金是陷阱

圖書館借閱系統(tǒng)源代碼

#includestdio.h #includestring.h #includeconio.h #includestdlib.h #includectype.h #define STACK_INIT_SIZE 10 #define OK 1 #define TRUE 1 #define FALSE 0 #define ERROR 0 struct student /*定義學(xué)生類型,用于存放借出的書籍*/ { int carnum; char lendbook[10]; }student[1000]; struct employ /*定義職工類型*/ { int employnum; char employname[15]; int employage; char employsex[2]; char employleve[10]; long int employtage; }employ[50]; struct book /*定義書的類型*/ { int booknum; char bookname[10]; char bookcreat[10]; int turefalse; /*用于借書和還書模塊判斷一本書是否借出的條件*/ }book[1000]; struct car /*借書卡的數(shù)據(jù)類型*/ { int carnum; char studentname[10]; int studentclass; }car[100]; huanbook() /*還書函數(shù)*/ { FILE *fp,*fp2; /*定義兩個(gè)文件指針,fp2用于修改數(shù)據(jù)時(shí)設(shè)立臨時(shí)文件用,防止數(shù)據(jù)遭破壞*/ int i,n; int carnum; char lendbook[10]; printf("請你輸入你的卡號\n"); scanf("%d",carnum); fp=fopen("car.txt","r"); /*讀取卡號記錄*/ for(i=0;fread(car[i],sizeof(struct car),1,fp)!=0;i++) /*for循環(huán)判斷卡號是否存在*/ { if(car[i].carnum==carnum) /*卡號存在,進(jìn)入下一循環(huán)*/ { n=i; fclose(fp); printf("請輸入你要還的書的名字\n"); scanf("%s",lendbook); fp=fopen("record.txt","r"); for(i=0;fread(student[i],sizeof(struct student),1,fp)!=0;i++) /*判斷是否借閱了輸入的書*/ { if(strcmp(student[i].lendbook,lendbook)==0) /*借閱了該書,進(jìn)入下一循環(huán),否則出錯顯示*/ { fclose(fp); fp=fopen("record.txt","r"); fp2=fopen("bookl.txt","w"); for(i=0;fread(student[i],sizeof(struct student),1,fp)!=0;i++) { if(strcmp(student[i].lendbook,lendbook)==0) { continue; /*刪除還掉的書的借書記錄*/ } fwrite(student[i],sizeof(struct student),1,fp2); /*寫入原來沒還的書的記錄*/ } fclose(fp); fclose(fp2); fp=fopen("record.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(student[i],sizeof(struct student),1,fp2)!=0;i++) { fwrite(student[i],sizeof(struct student),1,fp); /*將借書記錄信息寫回*/ } fclose(fp); fclose(fp2); fopen("bookl.txt","w"); /*清臨時(shí)文件的記錄*/ fclose(fp2); fp=fopen("book.txt","r"); fp2=fopen("bookl.txt","w"); for(i=0;fread(book[i],sizeof(struct book),1,fp)!=0;i++) /*將書的記錄寫入臨時(shí)文件,防止因?yàn)樾薷男畔⑵茐囊郧暗挠涗?/ { if(i==n) { book[i].turefalse=1; fwrite(book[i],sizeof(struct book),1,fp2); /*將還的書的原來狀態(tài)設(shè)為無人借閱的*/ continue; } fwrite(book[i],sizeof(struct book),1,fp2); } fclose(fp); fclose(fp2); fp=fopen("book.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(book[i],sizeof(struct book),1,fp2)!=0;i++) { fwrite(book[i],sizeof(struct book),1,fp); /*將臨時(shí)文件寫回*/ } fclose(fp); fclose(fp2); fopen("bookl.txt","w"); /*清臨時(shí)文件*/ fclose(fp2); printf("還書完畢,按任意鍵返回\n"); getch(); return 1; } } printf("你沒有借這樣的書,任意鍵返回\n"); /*出錯提示*/ fclose(fp); getch(); return 0; } } printf("系統(tǒng)沒這樣的卡,和管理員聯(lián)系,按任意鍵返回\n"); /*出錯提示*/ fclose(fp); getch(); } findbook() { FILE *fp; char bookname[10]; int ture,i; fp=fopen("book.txt","r"); printf("請輸入你要查找的書名\n"); scanf("%s",bookname); for(i=0;fread(book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(bookname,book[i].bookname)==0) { if(book[i].turefalse==1) { printf("這本書的詳細(xì)資料是:%d %s %s 此書現(xiàn)在無人借閱\n按任意鍵返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat); } else {printf("這本書已經(jīng)有人借出\n");fclose(fp);return 0;} fclose(fp); return FALSE; } } printf("沒有你要查詢的書籍\n"); fclose(fp); return FALSE; } findbook1() { FILE *fp; char bookcreat[10]; int ture,i; fp=fopen("book.txt","r"); printf("請輸入你要查找的作者名\n"); scanf("%s",bookcreat); for(i=0;fread(book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(bookcreat,book[i].bookcreat)==0) { if(book[i].turefalse==1) { printf("這本書的詳細(xì)資料是:%d %s %s 此書現(xiàn)在無人借閱\n按任意鍵返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat); } else {printf("這本書已經(jīng)有人借出\n");fclose(fp);return 0;} fclose(fp); return FALSE; } } printf("沒有你要查詢的書籍\n"); fclose(fp); return FALSE; } lendcount() { FILE *fp; int i,n=0; fp=fopen("record.txt","r"); for(i=0;fread(student[i],sizeof(struct student),1,fp)!=0;i++) { printf("卡號:%d 借出的書籍:%s \n",student[i].carnum,student[i].lendbook); n=n+1; } fclose(fp); printf("目前共有%d本書借出\n",n); printf("按任意鍵\n"); getch(); return n; } chabook() { char ch5; do { printf("---------------歡迎進(jìn)入圖書查詢系統(tǒng)!--------------\n"); printf(" 1:按書名查找\n"); printf(" 2:按作者查找\n"); printf(" 0:返回\n"); printf("請輸入0--2,其他輸入非法!\n"); scanf("%s",ch5); switch(ch5) { case '1':findbook();getch();break; case '2':findbook1();getch();break; case '0':break; default:printf("無此操作\n");getch();break; } }while(ch5!='0'); return FALSE; } lendbook() { FILE *fp,*fp2; int i,n; int carnum; printf("請你輸入你的卡號\n"); scanf("%d",carnum); fp=fopen("car.txt","r"); for(i=0;fread(car[i],sizeof(struct car),1,fp)!=0;i++) { if(car[i].carnum==carnum) { n=i; fclose(fp); printf("請輸入你要借閱的書的名字\n"); scanf("%s",student[n].lendbook); fp=fopen("book.txt","r"); for(i=0;fread(book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(book[i].bookname,student[n].lendbook)==0) { if(book[i].turefalse==0) {printf("對不起,此書有人借出,請借其他書\n");fclose(fp);getch();return;} else fclose(fp); fp=fopen("record.txt","a+"); student[n].carnum=carnum; fwrite(student[n],sizeof(struct student),1,fp); fclose(fp); fp=fopen("book.txt","r"); fp2=fopen("bookl.txt","w"); for(i=0;fread(book[i],sizeof(struct book),1,fp)!=0;i++) { if(strcmp(book[i].bookname,student[n].lendbook)==0) { book[i].turefalse=0; fwrite(book[i],sizeof(struct book),1,fp2); continue; } fwrite(book[i],sizeof(struct book),1,fp2); } fclose(fp); fclose(fp2); fp=fopen("book.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(book[i],sizeof(struct book),1,fp2)!=0;i++) { fwrite(book[i],sizeof(struct book),1,fp); } fclose(fp); fclose(fp2); fopen("bookl.txt","w"); fclose(fp2); printf("借書完畢,按任意鍵返回\n"); getch(); return; } } printf("不存在這樣的書,任意鍵返回\n"); fclose(fp); getch(); return; } } printf("你的卡號不存在,請申請新卡,按任意鍵返回\n"); fclose(fp); getch(); } carcount() { FILE *fp; int i,n=0; fp=fopen("car.txt","r"); for(i=0;fread(car[i],sizeof(struct car),1,fp)!=0;i++) { printf("第%d張卡卡號:%d 姓名:%s 班級:%d\n",i+1,car[i].carnum,car[i].studentname,car[i].studentclass); n=n+1; } fclose(fp); printf("目前共有%d本書\n",n); printf("按任意鍵\n"); getch(); } delcar() { FILE *fp,*fp2; int i; int carnum; char choice; fp=fopen("car.txt","r"); fp2=fopen("bookl.txt","w"); printf("請輸入你要刪除的卡號\n"); printf("如果你輸入的卡號存在,系統(tǒng)自動刪除該信息!如果不存在,系統(tǒng)不做任何改動\n"); scanf("%d",carnum); for(i=0;fread(car[i],sizeof(struct car),1,fp)!=0;i++) { if(car[i].carnum!=carnum) { fwrite(car[i],sizeof(struct car),1,fp2); } } fclose(fp); fclose(fp2); printf("是否真的要刪除該卡?刪除后該書籍的所有信息將無法恢復(fù)《Y/N》\n"); scanf("%s",choice); if(choice=='y'||choice=='Y') { fp=fopen("car.txt","w"); fp2=fopen("bookl.txt","r"); for(i=0;fread(car[i],sizeof(struct car),1,fp2)!=0;i++) { fwrite(car[i],sizeof(struct car),1,fp); } fclose(fp); fclose(fp2); fp2=fopen("bookl.txt","w"); fclose(fp2); printf("按任意鍵返回\n"); getch(); return; } else { printf("按任意鍵返回\n"); getch(); return; } } addcar() { FILE *fp; int i=0; fp=fopen("car.txt","a+"); printf("請你輸入卡號\n"); scanf("%d",car[i].carnum); printf("請你輸入學(xué)生姓名\n"); scanf("%s",car[i].studentname); printf("請你輸入班級\n"); scanf("%d",car[i].studentclass); fwrite(car[i],sizeof(struct car),1,fp); fclose(fp); printf("輸入完畢,任意鍵返回\n"); getch(); }

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

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

給你修改了三個(gè)地方:

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

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

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

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("對不起,一個(gè)人只能借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("價(jià)格:" + price);

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

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

}

}

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


當(dāng)前題目:包含教室借閱系統(tǒng)java代碼的詞條
標(biāo)題來源:http://weahome.cn/article/hosjih.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部