package com.suncheng.main
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.FileWriter
import java.io.IOException
import java.io.InputStreamReader
public class Main {
//路径
private final static String PATH = "D:\\"
//图书录入.txt
private final static String TSLR = PATH+"图书录入.txt"
//人员信息.txt
private final static String RYXX = PATH+"人员信息.txt"
//借还书.txt
private final static String JS_HS = PATH+"借还书.txt"
static{
try {
String[][] arr = {{"图书ID,图书名称",TSLR},{"人员ID,姓名",RYXX},{"借还ID,借书人,开始借书时间,最终还书截至时间,还书时间,是否已还",JS_HS}}
for(int i = 0 i < arr.length i++){
getTitle(arr[i][0], arr[i][1])
}
} catch (IOException e) {
throw new RuntimeException("系统出现问题,请联系管理员!")
}
}
{
try {
init()
} catch (IOException e) {
e.printStackTrace()
}
}
public static void main(String[] args) throws IOException {
new Main()
}
//初始化菜单
private void init() throws IOException{
System.out.println("++++++++++++借书管理系统++++++++++++")
System.out.println("\t1). 图书的录入")
System.out.println("\t2). 人员信息的录入")
System.out.println("\t3). 图书的查询")
System.out.println("\t4). 借书的录入")
System.out.println("\t5). 还书的录入")
System.out.println("\t6). 人员借阅信息的显示")
System.out.println("请输入相应菜单:")
try {
int num = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in)).readLine())
switch(num){
case 1 :
getTSLR()
break
}
} catch (Exception e) {
e.printStackTrace()
}
}
//通用添加标题方法
private static void getTitle(String split,String path) throws IOException{
String[] arr = split.split(",")
BufferedWriter out = new BufferedWriter(new FileWriter(path))
for(int i = 0 i < arr.length i++){
out.write(arr[i]+"\t")
}
out.newLine()
out.close()
}
//添加图书方法
private boolean getTSLR() throws IOException{
boolean flag = false
FileWriter fw = new FileWriter(this.TSLR,true)
BufferedReader br = getSystem_In()
while(true){
System.out.println("请输入图书ID")
String id = br.readLine()
System.out.println("请输入图书姓名")
String name = br.readLine()
fw.write(id+"\t")
fw.write(name+"\t")
fw.write("\r\n")
System.out.println("是否继续添加 Y、N")
if(!"y".equalsIgnoreCase(br.readLine())){
break
}
}
fw.close()
br.close()
return flag
}
private BufferedReader getSystem_In(){
return new BufferedReader(new InputStreamReader(System.in))
}
}
//图书类
class Book{
private int id //图书ID
private String name //图书名称
}
//人员类
class Person{
private int id //人员ID
private String name //姓名
}
//借还信息类
class Person_Book{
private int id //借还ID
private String person //借书人
private String startDate //开始借书时间
private String stopDate //最终还书截至时间
private String hsDate //还书时间
private boolean flag //是否已还 true还,false未
}
package Managementimport java.util.List
import java.util.ArrayList
public class Management {
public static List<Book> bookList=null
public Management() {
// TODO Auto-generated constructor stub
bookList=new ArrayList<Book>(100)
}
public void addbook(Book book)
{
bookList.add(book)
}
public Book[] findBook(String bookName)
{
Book [] book=new Book[100]
int j=0
for(int i=0i<bookList.size()i++)
{
if(bookName.equals(bookList.get(i).getName()))
{
book[j]=bookList.get(i)
j++
}
}
return book
}
public Book[] ShowAllBook()
{
Book[]book=new Book[100]
for(int i=0i<bookList.size()i++)
{
book[i]=bookList.get(i)
bookList.get(i).printInfo()
}
return book
}
}
class Book
{
private String name
private String author
public String getName() {
return name
}
public void setName(String name) {
this.name = name
}
public String getAuthor() {
return author
}
public void setAuthor(String author) {
this.author = author
}
void printInfo()
{
System.out.println("书名为"+this.name+"作者为"+this.author)
}
}
class Reader
{
private String name
public void borrowbook(Book book) {
Management liabry=new Management()
for(int i=0i<liabry.bookList.size()i++)
{ if(book.getAuthor().equals(liabry.bookList.get(i).getAuthor())&&book.getName().equals(liabry.bookList.get(i).getName()))
{
liabry.bookList.remove(i)
System.out.println("借书成功!")
break
}
}
}
public void backbook(Book book) {
Management liabry=new Management()
liabry.addbook(book)
System.out.println("还书成功")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)