




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、package library;import java.io.*;import java.util.ArrayList;/* * Created by Fantanstic boy on 2016/5/14. */public class LoadBorrower implements LoadInterfaceBorrow public void load(BorrowerDatabase borrowerDatabase) / TODO Auto-generated method stubString FileName2 = "users.txt"File myFile
2、 = new File(FileName2);if (!myFile.exists() System.err.println("Can't Find " + FileName2);ArrayList<String> str = new ArrayList<String>();try BufferedReader in = new BufferedReader(new FileReader(myFile);String temp;for (int i = 0; (temp = in.readLine() != null; i+) str.add
3、(temp);in.close(); catch (IOException e) e.getStackTrace();for (String s : str) String dataofborrower = s.split("_");Borrower borrower = new Borrower(dataofborrower0,dataofborrower1);borrowerDatabase.addBorrower(borrower);public void reload(BorrowerDatabase borrowerDatabase) / TODO Auto-ge
4、nerated method stubString FileName2 = "users.txt"File myFile = new File(FileName2);if (!myFile.exists() System.err.println("Can't Find " + FileName2);ArrayList<String> str = new ArrayList<String>();try BufferedWriter in = new BufferedWriter(new FileWriter(FileName
5、2);String temp;for (int i = 0; i < borrowerDatabase.getNumberOfBorrowers(); i+) Borrower borrower = borrowerDatabase.getBorrower(i);temp = borrower.getId() + "_" + borrower.getName() + "n"str.add(temp);String result = ""for (String s : str)result += s;in.write(result
6、);in.close(); catch (IOException e) e.getStackTrace();for (String s : str) String dataofborrower = s.split("_");Borrower borrower = new Borrower(dataofborrower0,dataofborrower1);borrowerDatabase.addBorrower(borrower);package library;import java.io.*;import java.util.*;import static java.la
7、ng.Integer.parseInt;/* * Created by Fantanstic boy on 2016/5/16. */public class LoadBorroweritems implements LoadInterfaceBorrow public void load(BorrowerDatabase borrowerDatabase) String FileName4 = "useritems.txt"File myFile = new File(FileName4);if (!myFile.exists() System.err.println(&
8、quot;Can't Find " + FileName4);ArrayList<String> str = new ArrayList<>();try BufferedReader in = new BufferedReader(new FileReader(myFile);String temp;for (int i = 0; (temp = in.readLine() != null; i+) str.add(temp);in.close(); catch (IOException e) e.getStackTrace();for (int j
9、= 0; j < str.size(); j+) String string = str.get(j);String items = string.split("&&");for (int i = 0; i < items.length; i+) String s = str.get(i);String item = s.split("_");CatalogItem catalogitem;if (item0.equals("音像") catalogitem = new Recording(item1, i
10、tem2,parseInt(item3), item0, true, item5, item6); else if (item0.equals("書(shū)籍") catalogitem = new Book(item1, item2, parseInt(item3),item0, true, item5, parseInt(item6); elsecontinue;borrowerDatabase.getBorrower(j).getBorrowerItems().addItem(catalogitem);public void reload(BorrowerDatabase b
11、orrowerDatabase) String FileName1 = "useritems.txt"File myFile = new File(FileName1);if (!myFile.exists() System.err.println("Can't Find " + FileName1);ArrayList<String> str = new ArrayList<>();try String temp;for (int i = 0; i < borrowerDatabase.getNumberOfBor
12、rowers(); i+) BorrowerItems items = borrowerDatabase.getBorrower(i).getBorrowerItems();for (int j = 0; j < items.getNumberOfItems(); j+) CatalogItem item = items.getItem(j);if (item.getType().equals("書(shū)籍")temp = "書(shū)籍_" + item.getCode() + "_" + item.getTitle()+ "_&
13、quot; + item.getYear() + "_"+ item.isAvailable() + "_"+ (Book) item).getAuthor() + "_"+ (Book) item).getNumberOfPages();elsetemp = "音像_" + item.getCode() + "_" + item.getTitle()+ "_" + item.getYear() + "_"+ item.isAvailable() + &q
14、uot;_"+ (Recording) item).getPerformer() + "_"+ (Recording) item).getFormat();if (j + 1 < items.getNumberOfItems()temp += "&&"str.add(temp);String result = ""for (String s : str)result += s + "n"BufferedWriter in = new BufferedWriter(new FileWr
15、iter(myFile);in.write(result);in.close(); catch (IOException e) e.getStackTrace();package library;import java.io.*;import java.util.ArrayList;import static java.lang.Integer.parseInt;/* * Created by Fantanstic boy on 2016/5/14. */public class LoadCatalog implements LoadInterfaceCatalog public void l
16、oad(Catalog catalog) String FileName1 = "catalog.txt"File myFile = new File(FileName1);if (!myFile.exists() System.err.println("Can't Find " + FileName1);ArrayList<String> str = new ArrayList<String>();try BufferedReader in = new BufferedReader(new FileReader(myFi
17、le);String temp;for (int i = 0; (temp = in.readLine() != null; i+) str.add(temp);in.close(); catch (IOException e) e.getStackTrace();for (String s : str) String item = s.split("_");CatalogItem catalogitem;/ 音像_v004_BlackSheep _2008_true_Gin Wigmore_Mp3if (item0.equals("音像") catal
18、ogitem = new Recording(item1, item2,parseInt(item3), item0,(new Boolean(item4).booleanValue(), item5, item6); else if (item0.equals("書(shū)籍") / 書(shū)籍_a001_Java編程思想_2007_true_B.E_880catalogitem = new Book(item1, item2, parseInt(item3),item0, (new Boolean(item4).booleanValue(),item5, parseInt(item6
19、); elsecontinue;catalog.addItem(catalogitem);/* * 用于結(jié)尾時(shí)對(duì)各文件的重寫(xiě) * * param catalog */public void reload(Catalog catalog) String FileName1 = "catalog.txt"File myFile = new File(FileName1);if (!myFile.exists() System.err.println("Can't Find " + FileName1);ArrayList<String>
20、str = new ArrayList<String>();try String temp;for (int i = 0; i < catalog.getNumberOfItems(); i+) CatalogItem item = catalog.getItem(i);if (item instanceof Book)/ 書(shū)籍_a001_Java編程思想_2007_true_B.E_880temp = "書(shū)籍_" + item.getCode() + "_" + item.getTitle() + "_"+ ite
21、m.getYear() + "_" + item.isAvailable() + "_"+ (Book) item).getAuthor() + "_"+ (Book) item).getNumberOfPages();/ 音像_v004_Black Sheep _2008_true_Gin Wigmore_Mp3elsetemp = "音像_" + item.getCode() + "_" + item.getTitle() + "_"+ item.getYear() +
22、"_" + item.isAvailable() + "_"+ (Recording) item).getPerformer() + "_"+ (Recording) item).getFormat();str.add(temp);String result = ""for (String s : str)result += s + "n"BufferedWriter in = new BufferedWriter(new FileWriter(myFile);in.write(result);
23、in.close(); catch (IOException e) e.getStackTrace();package library;public interface LoadInterfaceBorrow void load(BorrowerDatabase database);void reload(BorrowerDatabase database);package library;public interface LoadInterfaceCatalog void load(Catalog catalog);void reload(Catalog catalog);package l
24、ibrary;public interface LoadInterfaceManager void load(ManagerDatabase database);void reload(ManagerDatabase database);package library;import java.io.*;import java.util.*;/* * Created by Fantanstic boy on 2016/5/14. */public class LoadManager implements LoadInterfaceManager public void load(ManagerD
25、atabase managerDatabase) String FileName3 = "managers.txt"File myFile = new File(FileName3);if (!myFile.exists() System.err.println("Can't Find " + FileName3);ArrayList<String> str = new ArrayList<String>();try BufferedReader in = new BufferedReader(new FileReader(myFile);String temp;for (int i = 0; (temp = in.readLine() != null; i+) str.add(temp);in.close(); catch (IOException e) e.getStackTrace();for (String s : str) String dataOfManager = s.split("_");Manager manager = new Manager(dataOfManager0, dataOfManager1);managerDat
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 航空航天復(fù)合材料 課件第1章 知識(shí)點(diǎn)6 微珠、納米碳管、石墨烯、有機(jī)纖維
- 2025醫(yī)院消防培訓(xùn)
- 護(hù)理查房:下肢骨折透析患者管理
- 長(zhǎng)度計(jì)量基礎(chǔ)培訓(xùn)
- 創(chuàng)傷處理培訓(xùn)
- 超聲圖解及報(bào)告標(biāo)準(zhǔn)化流程
- 地球日環(huán)保教育
- 2025年中國(guó)排毒面膜行業(yè)市場(chǎng)全景分析及前景機(jī)遇研判報(bào)告
- 急性闌尾炎及術(shù)后護(hù)理常規(guī)
- 2025年中國(guó)木工油漆刷行業(yè)市場(chǎng)全景分析及前景機(jī)遇研判報(bào)告
- 成都東方廣益投資有限公司下屬企業(yè)招聘筆試真題2024
- 2025年高考英語(yǔ)全國(guó)二卷試題含答案
- SL631水利水電工程單元工程施工質(zhì)量驗(yàn)收標(biāo)準(zhǔn)第1部分:土石方工程
- 江岸區(qū)2023-2024學(xué)年下學(xué)期期末七年級(jí)數(shù)學(xué)試卷(含答案)
- 《國(guó)土空間規(guī)劃》-課程教學(xué)大綱
- (正式版)HGT 22820-2024 化工安全儀表系統(tǒng)工程設(shè)計(jì)規(guī)范
- 2024年海關(guān)事務(wù)培訓(xùn)資料
- 幼兒園大班畢業(yè)典禮教師詩(shī)朗誦
- 【部編人教版】貴州省銅仁市2021-2022年八年級(jí)下期末數(shù)學(xué)試卷
- 礦用隔爆兼本安型電子皮帶秤技術(shù)規(guī)格書(shū)
- 冀教版七年級(jí)英語(yǔ)下冊(cè)期末試題-附答案
評(píng)論
0/150
提交評(píng)論